thinkphp access process in the manual 1.11 system flow is introduced, I read the thinkphp version is 3.1.3, we can look at the manual, the basic process also has, now is detailed to introduce the thinkphp of the access process. (in debug mode, in the deployment mode, the intermediate URL parsing, file loading and the like, are encapsulated in a file)
1. Entry file (index.php)
The most common entry file is index.php, where you can define the project name, path, cache file storage path, and so on. Last to load thinkphp/thinkphp.php
The place to point to the next file is require ' thinkphp/thinkphp.php ';
2.thinkphp/thinkphp.php
This file defines the basic system directory constants, the framework engine judgment, and the deployment mode and debug mode judgment
The place to point to the next file is require Think_path. ' Common/runtime.php ';
3.runtime.php (~runtime.php)
PHP environment judgment, URL definition, project directory constant definition, core file loading, project directory generation.
The place to point to the next file is Think::start ();
4.think.class.php
Error mode definition, exception definition, set auto load, cache configuration parameters, language parameters, etc.
App::run ();
5.app.class.php
Set the time zone, load the dynamic project public files and configuration files, some system constants definitions, such as (is_post), etc., Post,get and other value filtering,
The place to point to the next file is dispatcher::d Ispatch (); On line 38th of App.class.php
6.dispatcher.class.php
URL parsing, get the group, module, operation name, including URL four ways of detailed definition, URL route are defined here.
After parsing is complete, go back to App.class.php and execute app.exec
7.app.class.php app::exec
Execution of the application, including pre-and post-operation execution, current method execution, and empty module judgments (e.g. IndexAction.class.php, etc., will be executed directly here)
In the execution of IndexAction.class.php, there is extends inheritance Action.class.php
8.action.class.php base class
Materialized view class assignment value, pass value to view, get action,ajax judgment, there are many methods, it is worth careful study.
When calling Assign,display,show and other methods, the operation will be done in the view.
9.view.class.php View class
Includes the ability to get variables defined in IndexAction.class.php, as well as parsing templates, output templates, and more
The method of executing the next file is tag (' View_parse ', $params); In the View.class.php View::fetch method.
ParseTemplateBehavior.class.php Template Parsing
In fact, it is the judgment of the cache and the template engine to use to parse the template.
In $TPL = think::instance (' thinktemplate '); In line 62nd
A. ThinkTemplate.class.php thinkphp template Parsing class
Here is the real template parsing, including the analysis of the system label, as well as the definition of the custom label, the parsing is completed directly into the cache and then include