PHP Recess Framework Primer

Source: Internet
Author: User

        • Recess installation
        • Recess Framework Introduction
        • Framework Configuration Items
        • Controllers and views
        • Routing route and routing annotations
        • Model Models
        • Application Management Tools
        • Reference

Recess Installation:
#install:unzip  recess-v0.20.to apache DocumentRoot (/var/www/html)#install5.3.3yum install php53-pdoyum install php53-mysql
Recess Framework Introduction

Recess is an open source, lightweight, RESTful PHP framework, and its application is divided into 3 chunks of models, views and controllers, respectively, and the MVC model corresponding;

A application is placed under/apps by default. The recess framework can handle multiple applications at the same time. Under Apps is a subdirectory of the application, such as:/apps/{appname}/, such as:

Application-specific configuration appNameApplication.class.php must inherit the framework's application class

Framework Configuration Items

Located in the framework configuration file recess-conf.php;
Specific application configuration needs to be added to the configuration item RecessConf::$applications
Database is configured toRecessConf::$namedDatabases

Controllers and Views:

The default execution process, first select (route) a controller (i.e. the Applied controller Class) method execution, and then select a view to respond to HTTP response
1. Controller controllers are responsible for which view template is used.
2. The default application controller file is apps/appname/controllers/appnamehomecontroller.class.php
3. Call View $this->ok (' View-name ') in the Controller method
4. Variables in the controller are passed to the view with the same name by default
5. Controller's method if you do not call exit, the default is to call back a view with the same name as the method
6. Controller controllers can pass data to view views through variables, such as the following method in the controller appNameHomeController.class.php modetest:

    /** !Route GET,/m */function modetest() {    $this‘will pass view modetest‘;}

The call variable ViewData in the view modetest. html.php is:

<?phpprint$viewdata;?>
Routing route and route annotations:

The route is completed in the controller, and the received request URL is distributed to the specific point of the application (the controller's method) for processing, which is done through the route annotations. The route annotations routeannotation syntax form:
/** !Route HTTP-method, URL-path */
It has 2 parameters, the first Http-method is the method of HTTP, such as GET, POST, PUT, or DELETE;
The second parameter, Url-path, is the URL path part, and if it contains a "$" symbol, it becomes the parameter of the corresponding method parameter
Url-path if not, the default form of accessappName/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 Models

It is related to data operation and implements CRUD operation of database. Can be used with include to controller controllers

Application Management Tools

The recess framework comes with a help tool that can be used to create and manage apps with access paths of http://{$installUrl}/recess/
If you want to see all the restful interfaces for your app, accesshttp://{$installUrl}/recess/apps/appNameApplication

Reference

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

Getting Started with PHP recess framework

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.