CakePHP executes the main process

Source: Internet
Author: User

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, such as Auth. Article Pai_^
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.