Php Recess framework entry, recessframework

Source: Internet
Author: User

Php Recess framework entry, recessframework

      • Recess Installation
      • Recess framework Introduction
      • Framework configuration items
      • Controllers and Views
      • Route and route Annotation
      • Model
      • Application Management Tools
      • Reference

Recess installation:
#install:unzip  recess-v0.20.zip to apache DocumentRoot (/var/www/html)#install PHP 5.3.3yum install php53-pdoyum install php53-mysql
Recess framework Introduction

Recess is an open-source, lightweight RESTful PHP framework. Its Applications are divided into three major modules: Models, Views, and Controllers, which correspond to the MVC model respectively;

An application is put under/apps by default. The Recess framework can process multiple applications at the same time. The app sub-directory is shown below the apps, for example:/apps/{appName}/, for example:

AppNameApplication. class. php must inherit the Application class of the framework.

Framework configuration items

Located in the framework profile recess-conf.php;
The specific application configuration needs to be added to the configuration itemRecessConf::$applicationsMedium
The database is configuredRecessConf::$namedDatabases

Controllers and Views:

The default execution process is to select a (route) controller (that is, the application's controller class) method for execution, and then select a view as the response HTTP response
1. The Controller is responsible for which view template is used.
2. The default application controller file is apps/appName/controllers/appNameHomeController. class. php.
3. Call the view $ this-> OK ('view-name') in the Controller method ')
4. the variables in the controller are passed to the view with the same name by default.
5. If the Controller method is not calledExit, The call and method are returned by default.Same nameA view
6. The controller Controllers can pass data Views to the view through variables. For example, the Controller appNameHomeController. class. php has the following methods:Modetest:

    /** !Route GET,/m */function modetest() {    $this->viewdata = 'will pass view modetest';}

ViewModetestThe viewdata variable called in. html. php is:

Route and route annotation:

Route completes in the Controller and distributes the received request URL to the specific point of the application (the Controller method) for processing. The specific form is completed through the route annotation. Route annotation RouteAnnotation syntax format:
/** !Route HTTP-method, URL-path */
It has two parameters. The first HTTP-method is an HTTP method, such as GET, POST, PUT, or DELETE;
The second parameter URL-path is the URL path section. If it contains"$"Symbol, it will become the parameter method parameter of the corresponding method
If no URL-path exists, the default access mode is used.appName/methodName

class TestController extends Controller {  /** !Route GET */    function index() {         echo 'Hello PHP Community!'; exit;    }    /** !Route GET, /hello/$first/$last */    function aMethod($first, $last) {         echo "Hello $first $last!"; exit;    }}
Model

It is related to data operations to implement database CRUD operations. You can use the include function in the controller.

Application Management Tools

The Recess framework comes with a help tool that can be used to create and manage applications. The access path ishttp://{$installUrl}/recess/
If you want to view all the RESTful interfaces of the application, accesshttp://{$installUrl}/recess/apps/appNameApplication

Reference

The Book of Recess Official Guide to the Recess PHP Framework
Apache mod_rewrite Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.