ThinkPHP3.2 Loading Process (1), thinkphp3.2 Loading
Loading Process (Official introduction ):
User URL request
Call the app portal file (usually the index. php of the website)
Load the framework entry file (ThinkPHP. php)
Record the initial running time and memory overhead
System constant judgment and definition
Load the framework Bootstrap class (Think \ Think) and execute the Think: start method to initialize the application.
Set error handling and automatic loading
Call the Think \ Storage class for Storage initialization (the Storage type is defined by the STORAGE_TYPE constant)
In deployment mode, if an application compilation cache file exists, load the file directly (directly jump to step 22)
Read the definition file of the application mode (defined by the APP_MODE constant) (The following uses the normal mode as an example)
Load the core file defined in the current application Mode (the normal Mode is ThinkPHP/Mode/common. php)
Load the convention configuration file (the normal mode is ThinkPHP/Conf/convention. php)
Load the Application configuration file (the Common mode is Application/Common/Conf/config. php)
Load System alias Definition
Judge and read the Application alias definition file (the normal mode is Application/Common/Conf/alias. php)
Load System behavior Definitions
Determine and read the Application behavior definition file (the normal mode is Application/Common/Conf/tags. php)
Load the underlying Language Pack of the Framework (normal mode is ThinkPHP/Lang/zh-cn.php)
If the deployment mode is used, the application compilation cache file is generated.
Load the debugging mode system configuration file (ThinkPHP/Conf/debug. php)
Judge and read the debugging configuration file of the Application (default value: Application/Common/Conf/debug. php)
Judge the application status and read the status configuration file (if the APP_STATUS constant definition is not empty)
Check the application directory structure and generate it automatically (if the CHECK_APP_DIR configuration is enabled and the RUNTIME_PATH directory does not exist)
Call the run method of the Think \ App class to start the application.
APP initialization (app_init) Tag bit listens and executes binding behavior
Judge and load dynamic configuration and function files
Call Think \ Dispatcher: dispatch to schedule URL requests
Automatically identifies the $ _ SERVER ['path _ info'] parameter under the compatible URL mode and Command Line Mode
Deploy the detection domain name and bind the module and controller (the APP_SUB_DOMAIN_DEPLOY parameter is enabled)
Analyze the PATH_INFO information in the URL
Obtain the requested module information
Check whether the module exists and allows access
Determine and load module configuration files, alias definitions, behavior definitions, and function files
Judge and load the dynamic configuration and function file of the module
Module URL mode judgment
Module route detection (enabled by URL_ROUTER_ON)
PATH_INFO (path_info) Tag bit listening and binding
URL suffix detection (URL_DENY_SUFFIX and URL_HTML_SUFFIX processing)
Obtain the current controller, operations, and other URL parameters.
URL request Scheduling (url_dispatch) Tag bit listening and binding behavior
Application Start (app_begin) Tag bit listens and executes binding behavior
Call SESSION_OPTIONS to configure parameters for Session Initialization (if not in command line mode)
Execute Controller Method Based on request
If the Controller does not exist, check whether the empty controller exists.
The controller starts listening to the tag bit (action_begin) and executes the binding action.
By default, the system's ReadHtmlCache behavior is called to read the static cache (the HTML_CACHE_ON parameter is enabled)
Determine and call the Controller's _ initialize Initialization Method
Determines whether an operation method exists. If not, checks whether empty operation methods are defined.
Determine whether the pre-operation method is defined. If yes, execute
Action parameter binding Detection: automatically matches parameters of the Operation Method
If template rendering is available (call the Controller display method)
View start (view_begin) Tag bit listens and executes binding behavior
Call the fetch method of Think \ View to parse and obtain the template content
Automatically identifies the current topic and locates the Template File
View parsing (view_parse) Tag bit listens and executes binding behavior
Default call built-in ParseTemplate behavior parsing template (below normal mode)
The template engine parses the template content and generates the template cache.
Template_filter listens to and performs binding
By default, the ContentReplace action of the system is called to replace the template.
The output content filtering (view_filter) Tag bit listens and executes binding behavior
By default, the system's WriteHtmlCache behavior is called to write data to the static cache (the HTML_CACHE_ON parameter is enabled)
Call the render method of the Think \ View class to output the rendering content.
View end (view_end) Tag bit listens and executes binding behavior
Determine whether the post operation method is defined. If yes, execute
Controller ends (action_end) Tag bit listening and executes binding behavior
App_end tag listening and binding
Execute the ShowPageTrace action of the system (the SHOW_PAGE_TRACE parameter is enabled and is not an AJAX request)
Write log information storage
Code:
1. Entry file (index. php)
// Check the PHP environment if (version_compare (PHP_VERSION, '5. 3.0 ',' <') die ('require PHP> 5.3.0! '); // Enable the debugging mode. It is recommended that you enable the annotation of the deployment phase in the development phase or set it to falsedefine ('app _ debug', True ); // define the application directory define ('app _ path ','. /Application/'); // introduce the ThinkPHP entry file require '. /ThinkPHP. php ';
Purpose 1. Set whether the debug mode is used. (In debug mode, that is, when APP_DEBUG is set to True, the last compiled value is not loaded ~ In runtime. php development, we recommend that you start the debugging mode)
2. Define the APP_PATH path
3. it is also the most important entry to introduce ThinkPHP. This is the start of the complex and simple TP framework tour. If you do not have any equipment, you can bring the equipment, click the TP framework.
The following describes how the page appears without modifying the TP source code.
(PS: because the monks are also the first to learn the TP framework. They are also the first to learn PHP. They hope to write some of their own experiences here and organize their own ideas. They also hope to help everyone raise their own ideas if they have any mistakes.)