Home  >  Article  >  Backend Development  >  Process analysis of Zend framework processing an http request_PHP tutorial

Process analysis of Zend framework processing an http request_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:41:35950browse

zend framework 处理请求流程图

1, first is the bootstrap process, the resources used in the initialization 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 request and http reply, 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, which 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 a Zend_View entity object. 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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321159.htmlTechArticle1. 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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn