Cakephp executes the main process

Source: Internet
Author: User
Cakephp executes the main process. For more information about learning cakephp, see.

Cakephp executes the main process. For more information about learning cakephp, see.

Load basic files
The common methods and time constants are defined in cake/basics. php.
$ TIME_START = getMicrotime (); record start execution time
Some basic paths are defined in cake/config/paths. php.
Basic classes of cake/lib/object. php cake
Cake/lib/inflector. php is mainly used to process the singular and plural numbers, with the following name and the hump name.
Cake/lib/configure. php provides file configuration read/write, path settings, and file loading methods.
Cake/lib/cache. php cache operations

Configure: getInstance ();
Config/core. php project configuration file
Config/bootstrap. php project entry file

App: import ('core', array ('dispatcher '); load the Core and start doing business. GO
$ Dispatcher = new Dispatcher ();
$ Dispatcher-> dispatch ($ url); start to execute. By parsing the current url, if you set to compress Js and Css, compress the output of these files, if you set cache for the page, you can directly output the cache page and find the corresponding Controller. If no error is found, handle the error accordingly.
Instantiate the current Controller, determine the view path, and instantiate the Component to obtain the method that only the current Controller [does not contain the parent class Controller ].
Protects private methods, admin routes, or prefix methods in the current Controller. Direct access is not allowed.
Set basic attributes of the current Controller, such as base, here, webroot, plugin, params, action, passedArgs [array_merge ($ this-> params ['pass'], $ this-> params ['named'])]
Call the constructClasses method in Controller
Execute the _ mergeVars method, which performs special merge processing on attributes such as components, helpers, and uses of parent and child classes.
Call the Component-> init () method to load the series of components set by the user (the Session is the default), and the default enabled attribute is true. (This attribute can be modified later in beforeFilter)
Call the Component-> initialize () method. If the initialize method exists in the series of components and the enabled value of the component is true, call the components-> initialize method (here, the enabled user does not seem to be able to be set through the Controller, and can only be true)
Call the beforeFilter () method in the current Controller. This method is a good thing.
Call the Component-> startup () method. Similarly, if the startup method exists in the series components and the enabled value of the component is true, call the components-> startup method (enabled can be set through beforeFilter). This method is also the most important method in components. For example, Auth is here to write an article named ^_^.
Start to execute the Action Method in the Current Controller
If autoRender is set to true, the system calls the render () method of the current Controller. Otherwise, the system returns or outputs the data returned by the Action method.
When calling the Controller's render () method, call the beforeRender () method in the current Controller.
Load view rendering class
Call the Component-> beforeRender () method. Similarly, if this beforeRender method exists in the components series and the enabled of this component is true, call the components-> beforeRender method (enabled can be set through beforeFilter)
Obtain the data verification error message of the current Model for View
Call the render () method of View
Load related Helper Assistant
Call the beforeRender () method of Helper
Call the afterRender () method of Helper
Related cache Processing
Execute the renderLayout () method. Of course, you must allow the rendering layout. The default is the default. ctp layout file.
Call the beforeLayout () method of Helper
Call the afterLayout () method of Helper
Call the Component-> shutdown () method. Similarly, if the shutdown method exists in the series components and the enabled value of the component is true, call the components-> shutdown method (enabled can be set through beforeFilter)
Execute the afterFilter method in the current Controller. Here you can process the output content ($ controller-> output) of the view.
Returns or outputs View data.
The process is complete.

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.