Php 这些ZF事件以什么顺序运行?
这是一个Zend框架问题 如果我有一个控制器、一个动作助手和一个插件,它们的事件发生的顺序是什么?下面我按照我认为发生的顺序列出了我感兴趣的事件。顺序正确吗Php 这些ZF事件以什么顺序运行?,php,zend-framework,Php,Zend Framework,这是一个Zend框架问题 如果我有一个控制器、一个动作助手和一个插件,它们的事件发生的顺序是什么?下面我按照我认为发生的顺序列出了我感兴趣的事件。顺序正确吗 插件,routeStartup() 插件,routeShutdown() 插件,dispatchLoopStartup() 插件,preDispatch() 操作助手,init() 操作辅助程序,预剥离() 控制器,init() 控制器,preDispatch() 调度后控制器() 操作助手,postDispatch() 插件,postDi
这里有两个链接,其中有关于派遣流程的精彩图片。有趣的问题。我认为你是对的,除了7号和6号应该是对的。为了检查它,我调试了一个ZF应用程序。这就是我发现的:
1. $this->_plugins->routeStartup($this->_request); #$this is Zend_Controller_Front
$router->route($this->_request); #$router is Zend_Controller_Router_Rewrite, and method route finds a matching route to the current PATH_INFO
2. $this->_plugins->routeShutdown($this->_request); #$this is Zend_Controller_Front
3. $this->_plugins->dispatchLoopStartup($this->_request); #$this is Zend_Controller_Front
4. $this->_plugins->preDispatch($this->_request); #$this is Zend_Controller_Front
5. $helper->init(); # exectued for helpers by Zend_Controller_Action_HelperBroker
# during making an instance of IndexController.
# Specifically for Zend_Controller_Action_Helper_ViewRenderer
# and Zend_Layout_Controller_Action_Helper_Layout
// IndexControlles has just been instantiated
6. $this->init(); # $this is IndexController
7. $this->_helper->notifyPreDispatch(); # $this is IndexController
8. $this->preDispatch(); # $this is IndexController
$this->$action(); # $this is IndexController (action executed)
9. $this->postDispatch(); # $this is IndexController
10. $this->_helper->notifyPostDispatch(); # $this is IndexController
// Execution of IndexController has just finished
11. $this->_plugins->postDispatch($this->_request); #$this is Zend_Controller_Front
12. $this->_plugins->dispatchLoopShutdown(); #$this is Zend_Controller_Front
// after that response is sent
$this->_response->sendResponse(); #$this is Zend_Controller_Front
希望这能有所帮助。你好,阿内里,谢谢你的回复。序列图很棒,但是它只涵盖了12个事件中的8个。谢谢Marcin,这太棒了!