Mohamed Sharaf

The life of a request in Zend Framework 1

Where plugins and helpers run while Zend Framework 1 turns a URL into a response.

· 1 min read

From the archive: in 2012 I shared “Zend Framework MVC Request Lifecycle” by Kevin Schroeder on my old blog. This page is a short summary in my own words; the original belongs to its author.

Kevin Schroeder, who taught Zend Framework training courses, noticed that the plugin architecture confused students until they saw the request lifecycle drawn out. Here is that flow for Zend Framework 1, as hooks you can attach code to:

  1. routeStartup: before the URL is matched
  2. routing: the router picks the module, controller and action
  3. routeShutdown: after routing
  4. dispatchLoopStartup: once, before dispatching starts
  5. the dispatch loop, for each action (an action can forward to another):
    • preDispatch (plugins), then the controller’s init(), preDispatch(), the action itself, and postDispatch()
    • postDispatch (plugins)
  6. dispatchLoopShutdown: once, after the loop
  7. the response is sent

Rule of thumb from that era: front controller plugins for things that apply to every request (authentication, HTTPS, logging), action helpers for things specific controllers need.

Read the original: Zend Framework MVC Request Lifecycle, by Kevin Schroeder.

ShareWhatsAppLinkedInXTelegramFacebook