Pragmatism in the real world

A list of ZF2 events

Both the Module Manager and the MVC system use the Event Manger extensively in order to provide “hook points” for you to add your own code into the application flow. This is a list of the events triggered by each class during a standard request with the Skeleton Application:

Module Manager

  • Zend\Module\Manager: loadModules.pre
  • For every module:
    • Zend\Module\Manager: loadModule.resolve
    • Zend\Module\Manager: loadModule
  • Zend\Module\Manager: loadModules.post

Application

Successful:

  • Zend\Mvc\Application: bootstrap
  • Zend\Mvc\Application: route
  • Zend\Mvc\Application: dispatch
    • Zend\Mvc\Controller\ActionController: dispatch (if controller extends this class)
  • Zend\Mvc\Application: render
  • Zend\View\View: renderer
  • Zend\View\View: response
  • Zend\Mvc\Application: finish

On an error in route or dispatch:

  • Zend\Mvc\Application: dispatch.error
  • Zend\Mvc\Application: render
  • Zend\View\View: renderer
  • Zend\View\View: response
  • Zend\Mvc\Application: finish

Note that routing and dispatching is also implemented using these registered events, so you can implement “pre” and “post” hooks by changing the priority of the listener that you register.

(Note: updated 29th May to reflect ZF2.0)