ThinkPHP 5 Lifecycle

TP5 developed some time ago with a small program, it is a bit familiar with TP5. TP5 is the latest version of a TP frame, with the previous three have a lot of difference, and some say laravel closer, in fact, fortunately, everyone has their different views, as long as they used them choose a more smoothly the framework just fine.

After I learn a framework of time, the beginning or look at the life cycle of a real understanding of the life cycle in order to achieve, in the details we can be a better understanding of the overall grasp of the whole framework.


1: entry file:

TP5 entry files in the public file, is the entrance to the whole process, of course, you can also move files to the root directory and edit the index.php file in the application directory and start the file directory just fine.

In this document, the function was simply to define the application directory, and then loads the boot file

 

 

2: Boot Files

Here we follow the guidance found start.php. I found it introduces base.php, in fact, base file is a boot file, which some variables constant load, as well as registration mechanisms, such as automatic loading mechanism.

Loading system constants defined;
loading environment variable definition file;
registration automatic loading mechanism;
registration error and exception handling;
load the convention configuration file;
execute the application;

 


3. Then on to the application-based
application class a first step initialization, including the following sections:


Load Application (Public) configuration;
load the extended configuration file (defined by extra_config_list);
loading the application state configuration;
load alias definitions;
load behavior is defined;
loading public (function) files;
registration application namespace;
loaded extension function file (defined by extra_file_list );
set a default zone;
loading system language pack;

 


4.URL detected
after the initialization is complete URL will be detected, the address information acquisition request.

URL request must be PATHINFO format, otherwise it is considered illegal URL.

If the environment supports only a common format must be in the following format:


http://serverName/index.php?s=/index/index/hello&val=value

 


5. Route Detection

If you turn routing detection, the priority will URL routing to match, the match is successful walk by the scheduler, or left the default analysis identified.

Configured to open url_route_on

 

 

6. Request Distribution

This step is the most important part of the whole life cycle, but also our most contact part, our controller, the controller runs inside the URL to find ways according to the different scheduling,

After a series of our code, to give the results.

 

 

7. responsive to the output

When we controllers processed, return, there will Response class outputs the result returned to the client interface, we can specify the default format, usually json format.

 

 

8. End of program

In fact, when we Response class interface outputs the result, the whole life cycle is not over yet.

Up to now we have not when it comes to journaling, which are generally not written at the time of the life cycle is completed, so this time frame task is to put us in this life cycle information written to the log.

 

At this point, the entire life cycle.

Guess you like

Origin www.cnblogs.com/bugstars/p/12389164.html