Home  >  Article  >  Backend Development  >  cakephp Cakephp executes the main process

cakephp Cakephp executes the main process

WBOY
WBOYOriginal
2016-07-29 08:42:22948browse

Load the basic file
cake/basics.php which defines commonly used methods and time constants
$TIME_START = getMicrotime(); records the start execution time
cake/config/paths.php which defines some basic paths
cake/lib/object. The basic class of php cake
cake/lib/inflector.php here mainly deals with singular and plural numbers, underlined naming and camel case naming
cake/lib/configure.php which provides reading and writing of file configuration, path setting, and Method of loading files
cake/lib/cache.php Cache operation
Configure::getInstance(); Start configuring the project
config/core.php Configuration file of the project
config/bootstrap.php Entry file of the project
App ::import('Core', array('Dispatcher')); Load the core and start doing business, GO
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch($url); Start execution, pass For the current URL parsing, if you set up compressed Js and Css, these files will be compressed and output. If you set up a cache for the page, the cached page will be output directly, and finally the corresponding Controller will be found. If it cannot be found, appropriate error handling is performed.
Instantiate the current Controller, determine the view path, instantiate the Component, and obtain the methods of only the current Controller [not including the parent class Controller]
Protect the private methods, methods with admin routing or prefix in the current Controller, and do not allow direct access
Set the 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 the Controller
Execute the __mergeVars method, which performs special merging processing of components, helpers, uses and other attributes of the parent and child classes
Call the Component->init() method to load the series of components (Session) set by the user is the default), and the default enabled attribute is true. (This property can be modified later in beforeFilter)
Call the Component->initialize() method. If there is this initialize method in the series of components and the component's enabled is true, then call the components->initialize method (here the enabled user It seems that it cannot be set through the Controller, it 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 there is this startup method in the series components And if the enabled of the component is true, then the components->startup method is called (enabled here can be set through beforeFilter). This method is also the most important method in components. For example, Auth is here to make a big fuss ^_^
Start execution Action method in the current Controller
If autoRender is set to true, the render() method of the current Controller will be called, otherwise the data returned by the Action method will be returned or output. When calling the render() method of the Controller, first call the render() method of the current Controller. The beforeRender() method
loads the view rendering class
calls the Component->beforeRender() method. Similarly, if there is this beforeRender method in the series of components and the component's enabled is true, the components->beforeRender method is called (here enabled Can be set through beforeFilter)
Get the data validation error information of the current Model and use it for the View
Call the View's render() method
Load the relevant Helper
Call the Helper's beforeRender() method
Call the Helper's afterRender() method
Related Cache processing
Execute the renderLayout() method, of course, you must allow rendering layout, the default is the default.ctp layout file
Call the Helper's beforeLayout() method
Call the Helper's afterLayout() method
Call the Component->shutdown() Method, similarly, if there is this shutdown method in the series components and the component's enabled is true, the components->shutdown method is called (enabled here can be set through beforeFilter)
Execute the afterFilter method in the current Controller, here you can The output content of the view ($controller->output) does some processing and returns or outputs the view data.
The process is completed.
The above introduces the main process of cakephp Cakephp execution, including cakephp content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn