One of the typical CakePHP requests in chapter 3 of CakePHP2.xCookBook

Source: Internet
Author: User
Ricardo clicked the link pointing to http://www.example.com/cakes/buy, and the browser sent a request to your web server. A typical CakePHP request

We have covered the basic elements in CakePHP. let's see how objects work together to complete a basic request. The following is an example of the original request. let's imagine our friend Ricardo just clicked "Buy A Custom Cake Now!" on the login page of the CakePHP application !" Link.


The flowchart shows a standard CakePHP request.

Number: 2. standard CakePHP request.

Black = essential elements, gray = optional elements, blue = callback

  1. Ricardo clicked a link pointing to the http://www.example.com/cakes/buy and its browser sent a request to your web server.
  2. This URL is used to obtain the parameters in the request: Controller, action, and all the remaining parameters that affect the business logic in the request.
  3. Using routing, the request URL is mapped to a controller action (a method of a specific controller class ). In this example, it is the bug () method of CakesController. The beforeFilter callback method of this controller will be called before all its logical actions are executed.
  4. The controller may use the model to obtain application data. In this example, the controller uses the model to match the last order of Ricardo from the database. All available model callbacks, behaviors, and data sources will be applied in this operation. The model is not mandatory, but all CakePHP controllers initialize at least one model.
  5. When the model obtains the data, it returns it to the controller, and the model callback is applied.
  6. The controller may use components to further improve data or perform other operations (such as session processing, permissions, or email sending ).
  7. Once the controller has prepared data using models and components, the data is transmitted to the view using the set () method of the controller. Controller callback may be called before data transmission. View logic is executed, which may include elements and/or assistants. By default, a view is rendered in a layout.
  8. Additional controller reconciliation (such as afterFilter) may be applied. After everything is done, the rendered view code is transferred to Ricardo's browser.

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.