Zend Framework 2 Event Reference

The following lists represent the structure of events and listeners in a standard Zend Framework 2 Application. It starts with the module manager events that are triggered when Zend\ModuleManager\ModuleManager::loadModules() is called followed by the application events triggered by Zend\Mvc\Application::bootstrap() and Zend\Mvc\Application::run(). Listeners are listed by their priority and events are structure in a way that tries to illustrate where they triggered in the application. However events may also be triggered differently depending on application state. For example the dispatch.error and render.error events may be triggered at different places when an error is detected with the application. The event structure is also specific to ZF2 version 2.4.2. Different version may have different listener and event triggers.

Read more here: http://sporkcode.com/blog/2015/05/20/events-reference-for-zf2-applications/

Module Events (Zend\ModuleManager\ModuleManager, module_manager)

  1. loadModules
    1. Zend\Loader\ModuleAutoloader :: register
      Priority
      9000
      Identifier
      *
    2. Zend\ModuleManager\Listener\ConfigListener :: onloadModulesPre
      Priority
      1000
      Identifier
      *
    3. Zend\ModuleManager\ModuleManager :: onLoadModules
      Priority
      1
      Identifier
      *

      Load Module (Zend\ModuleManager\ModuleManager, module_manager)

      1. loadModule.resolve
        1. Zend\ModuleManager\Listener\ModuleResolverListener :: INVOKABLE
          Priority
          1
          Identifier
          *
      2. loadModule
        1. Zend\ModuleManager\Listener\AutoloaderListener :: INVOKABLE
          Priority
          9000
          Identifier
          *
        2. Zend\ModuleManager\Listener\ModuleDependencyCheckerListener :: INVOKABLE
          Priority
          8000
          Identifier
          *
        3. Zend\ModuleManager\Listener\InitTrigger :: INVOKABLE
          Priority
          1
          Identifier
          *
        4. Zend\ModuleManager\Listener\OnBootstrapListener :: INVOKABLE
          Priority
          1
          Identifier
          *
        5. Zend\ModuleManager\Listener\LocatorRegistrationListener :: onLoadModule
          Priority
          1
          Identifier
          *
        6. Zend\ModuleManager\Listener\ConfigListener :: onLoadModule
          Priority
          1
          Identifier
          *
        7. Zend\ModuleManager\Listener\ServiceListener :: onLoadModule
          Priority
          1
          Identifier
          *
    4. Zend\ModuleManager\Listener\LocatorRegistrationListener :: onLoadModules
      Priority
      -1000
      Identifier
      *
    5. Zend\ModuleManager\Listener\ConfigListener :: onLoadModules
      Priority
      -1000
      Identifier
      *

      Configure Modules (Zend\ModuleManager\ModuleManager, module_manager)

      1. mergeConfig
        1. Zend\ModuleManager\Listener\ConfigListener :: onMergeConfig
          Priority
          1000
          Identifier
          *
  2. loadModules.post
    1. Zend\ModuleManager\Listener\ServiceListener :: onLoadModulesPost
      Priority
      1
      Identifier
      *

Application Events (Zend\Mvc\Application)

  1. bootstrap
    1. Zend\Mvc\View\Http\ViewManager :: onBootstrap
      Priority
      10000
      Identifier
      *
    2. Zend\ModuleManager\Listener\LocatorRegistrationListener :: CLOSURE
      Priority
      1000
      Identifier
      Zend\Mvc\Application
  2. route
    1. Zend\Mvc\HttpMethodListener :: onRoute
      Priority
      10000
      Identifier
      *
    2. Zend\Mvc\RouteListener :: onRoute
      Priority
      1
      Identifier
      *
  3. dispatch
    1. Zend\Mvc\DispatchListener :: onDispatch
      Priority
      1
      Identifier
      *

      Controller Events (Zend\Mvc\Controller\AbstractController, SporkTools\Core\View\Helper\Controller, SporkTools, Zend\ServiceManager\ServiceLocatorAwareInterface, Zend\Mvc\InjectApplicationEventInterface, Zend\EventManager\EventsCapableInterface, Zend\EventManager\EventManagerAwareInterface, Zend\Stdlib\DispatchableInterface)

      1. dispatch
        1. SporkTools\Core\View\Helper\Controller :: onDispatch
          Priority
          1
          Identifier
          *
        2. Zend\Mvc\View\Http\CreateViewModelListener :: createViewModelFromArray
          Priority
          -80
          Identifier
          Zend\Stdlib\DispatchableInterface
        3. Zend\Mvc\View\Http\CreateViewModelListener :: createViewModelFromNull
          Priority
          -80
          Identifier
          Zend\Stdlib\DispatchableInterface
        4. Zend\Mvc\View\Http\RouteNotFoundStrategy :: prepareNotFoundViewModel
          Priority
          -90
          Identifier
          Zend\Stdlib\DispatchableInterface
        5. Zend\Mvc\View\Http\InjectTemplateListener :: injectTemplate
          Priority
          -90
          Identifier
          Zend\Stdlib\DispatchableInterface
        6. Zend\Mvc\View\Http\InjectViewModelListener :: injectViewModel
          Priority
          -100
          Identifier
          Zend\Stdlib\DispatchableInterface
    2. Zend\Mvc\View\Http\RouteNotFoundStrategy :: prepareNotFoundViewModel
      Priority
      -90
      Identifier
      *
  4. dispatch.error
    1. Zend\Mvc\View\Http\RouteNotFoundStrategy :: detectNotFoundError
      Priority
      1
      Identifier
      *
    2. Zend\Mvc\View\Http\RouteNotFoundStrategy :: prepareNotFoundViewModel
      Priority
      1
      Identifier
      *
    3. Zend\Mvc\View\Http\ExceptionStrategy :: prepareExceptionViewModel
      Priority
      1
      Identifier
      *
    4. Zend\Mvc\View\Http\InjectViewModelListener :: injectViewModel
      Priority
      -100
      Identifier
      *
  5. render
    1. Zend\Mvc\View\Http\DefaultRenderingStrategy :: render
      Priority
      -10000
      Identifier
      *

      View Events (Zend\View\View)

      1. renderer
        1. Zend\View\Strategy\PhpRendererStrategy :: selectRenderer
          Priority
          1
          Identifier
          *
      2. response
        1. Zend\View\Strategy\PhpRendererStrategy :: injectResponse
          Priority
          1
          Identifier
          *
  6. render.error
    1. Zend\Mvc\View\Http\ExceptionStrategy :: prepareExceptionViewModel
      Priority
      1
      Identifier
      *
    2. Zend\Mvc\View\Http\InjectViewModelListener :: injectViewModel
      Priority
      -100
      Identifier
      *
    3. Zend\Mvc\View\Http\DefaultRenderingStrategy :: render
      Priority
      -10000
      Identifier
      *

      View Events (Zend\View\View)

      1. renderer
        1. Zend\View\Strategy\PhpRendererStrategy :: selectRenderer
          Priority
          1
          Identifier
          *
      2. response
        1. Zend\View\Strategy\PhpRendererStrategy :: injectResponse
          Priority
          1
          Identifier
          *
  7. finish
    1. Zend\Mvc\SendResponseListener :: sendResponse
      Priority
      -10000
      Identifier
      *

      Response Events (Zend\Mvc\SendResponseListener)

      1. sendResponse
        1. Zend\Mvc\ResponseSender\PhpEnvironmentResponseSender :: INVOKABLE
          Priority
          -1000
          Identifier
          *
        2. Zend\Mvc\ResponseSender\ConsoleResponseSender :: INVOKABLE
          Priority
          -2000
          Identifier
          *
        3. Zend\Mvc\ResponseSender\SimpleStreamResponseSender :: INVOKABLE
          Priority
          -3000
          Identifier
          *
        4. Zend\Mvc\ResponseSender\HttpResponseSender :: INVOKABLE
          Priority
          -4000
          Identifier
          *