Home > Article > Backend Development > Zend framework Zend framework processes an http request process analysis
1. First is the bootstrap process, initializing the resources used in the program.
2. Create a Zend_Controller_Front entity to implement the front controller mode. This entity class will be responsible for dispatching http requests to the appropriate controller action.
3, Front controller will create two objects to encapsulate http requests and http replies, namely Zend_Controller_Request_Http and Zend_Controller_Response_Http
4, Front controller will create two objects to implement url path finding and dispatch, namely routing and dispatcher, They are respectively responsible for finding the controller and action that the specified URL should execute, and loading the corresponding program file and executing the corresponding method.
5. Through the controller’s plugin mechanism, Zend_Controller_Action_ViewRenderer will create a view attribute for the controller’s entity class. This view is an entity object of Zend_View. It is also responsible for rendering the corresponding template file into the http response object after the controller action request is processed. Finally, the content of the response object will be output to the browser by the Front Controller.
6, In the fifth step, although the template file is located by the ViewRender helper object, it is executed by a member function of Zend_VIew (include into this template file), so the view object in the properties of the Controller All properties and member functions can be used in template files.
The life cycle of such an http request is over, and the browser obtains the content. When the controller's action specifies variables to be presented to the view, it usually interacts with the database through Zend_Db_Table to obtain data.
Interacting with the database to process data is called business logic. The template file also contains simple loops and other logic, which is called display logic.
In MVC implementation, Model is responsible for processing business logic, View is responsible for processing display logic, and Controller is responsible for coordinating these two parts. Therefore, the code of Controller should be as simple as possible, and it only exists as an agent.
The above introduces the process analysis of zend framework Zend framework processing an http request, including the content of zend framework. I hope it will be helpful to friends who are interested in PHP tutorials.