2015-08-19 15:05:30 Wednesday
A very good essay.
PHP Kernel Exploration
Summarize
1. Module Initialization Minit
Each PHP module/extension initializes internal variables and tells PHP where the function body is (to register its own function with PHP) when calling its own function.
2. Request initialization of Rinit
Initialize session, global variable ... And so on only some variable settings for the current request
Zend Engine converts PHP code to opcode
When a related module handler function is called, Zend Engine handles the request parameter information to these modules and then receives the returned result.
Zend Engine will return the results to the PHP kernel
The PHP kernel is then passed to the Web server
3. End Request Rshutdown
Releases resources such as memory or files that are requested at initialization
4. End Module Mshutdown
Reclaim the resources requested when the module is initialized
Multi-Process & multithreading
If it's every request for a process, every request comes with a 4-step top.
If it is multi-threaded, just perform a 1th step, after all the PHP modules are initialized, each processing incoming request will only execute rinit, after processing is done just release rinit resources, and do not release Minit requested resources for the next request to use, unless the Web server shuts down, Before executing Mshutdown
PHP life cycle