Cakephp performs the main flow

  • 2020-03-31 20:33:24
  • OfStack

Load the base file
Cake /basics. PHP defines common methods and time constants
$TIME_START = getMicrotime (); Record the start execution time
Some basic paths are defined in cake/config/paths.php
Cake /lib/object.php cake basic class
Cake /lib/inflector.php is all about dealing with singular and complex Numbers, slash names and hump names
Cake /lib/configure. PHP provides the file configuration read and write, the path Settings, and the method of loading the file
Cake /lib/cache.php cache operation

Configure: : getInstance (); Start configuring the project
Config /core.php project
Config /bootstrap.php project entry file

App: : import (' Core ', array (' the Dispatcher ')); Load the core and get to work, GO
$Dispatcher = new Dispatcher ();
$Dispatcher - > Dispatch ($url); Start the execution, by the current url resolution, if you set the compression Js, Css, then the compression of the output of these files, if you set the page cache, then directly output the cache page, finally find the corresponding Controller. If it cannot be found, the corresponding error handling occurs.
Instantiate the current Controller, determine the view path, instantiate the Component, and get the method for the current Controller only [without the parent class Controller]
Protect private methods in the current Controller, methods with admin routing, or methods with prefix, and do not allow direct access
Set the basic properties 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 method with a special merge of the components, helpers, USES, and other properties of the parent and child classes
Call the Component - > Init () method, loads the set of components set by the user (Session is the default), and sets the default enabled property to true. (this property can be modified later in beforeFilter)
Call the Component - > The initialize() method is called if the initialize method is in the set of components and the component is enabled true. The initialize method (the enabled user here cannot seem to be set through the Controller and can only be set to true)
Call the beforeFilter() method in the current Controller, which is a good thing to ^_^
Call the Component - > The startup() method, again, is called if the startup method is in a series of components and the component is enabled true. The startup method (where enabled can be set by beforeFilter) is also the most important method in components, such as Auth, which is written here
Start executing the Action method in the current Controller
If autoRender is set to true, call the current Controller's render() method, otherwise return or output the data returned by the Action method
When the render() method of the Controller is called, the beforeRender() method in the current Controller is first called
Load the view rendering class
Call the Component - > The beforeRender() method, again, is called if the beforeRender method is in a series of components and the component is enabled true. BeforeRender method (here enabled can be set by beforeFilter)
Gets the data validation error message for the current Model and gives it to the View to use
Call the View's render() method
Load the correlation Helper
Call the beforeRender() method of the Helper
Call the afterRender() method of the Helper
Related cache processing
Perform the renderLayout() method, of course, if you allow the renderLayout, default to the default.ctp layout file
Call the beforeLayout() method of the Helper
Call the afterLayout() method of the Helper
Call the Component - > The shutdown() method, again, is called if the shutdown method is in a series of components and the component is enabled true. Shutdown method (here enabled can be set by beforeFilter)
Execute the afterFilter method in the current Controller, where you can view the output ($Controller -> Output) do some processing
Returns or outputs view data.
The process is complete.

Related articles: