Zend Framework Basic Request Workflow Chart
V 1.01, Created by Polley Wong
End User’s Browser
Request for a page
URL
public/index.php
Requires application/ bootstrap.php
application/ bootstrap.php
Configure include paths
Prepares Front Controller
Pass in Environment (development/staging/...)
Register Custom Plugin Initializer that runs $this->initDb(); $this->initHelpers(); $this->initView(); $this->initPlugins(); $this->initRoutes(); $this->initControllers();
Pass in Optional Custom Request & Response Object
Runs Front Controller Dispatch
Runs
Front Controller Dispatch Workflow Chart
Front Controller
Front Controller Dispatch V 1.01, Created by Polley Wong
Instantiate Default Request Object if none provided
Instantiate Default Response Object if none provided
Register Request Object and Response Object with Plugin Broker No
Notify Plugin Broker of Router Startup
Start Routing
Notify Plugin Broker of Router Completion
No
Plugin Broker
More Plugins with routeStartup() method?
Yes
Run Plugin’s routeStartup()
More Plugins with routeShutdown() method?
Yes
Run Plugin’s routeShutdown()
Router
Find a matching route to the current PATH_INFO
Extract Module, Controller, Action and Parameters
Inject returning values to the Request Object
Runs
Front Controller Dispatch Workflow Chart
Front Controller
Front Controller Dispatch
V 1.01, Created by Polley Wong
Routing Process
Instantiate Default Request Object if none provided Instantiate Default Response Object if none provided Register Request Object and Response Object with Plugin Broker No No Notify Plugin Broker of Router Startup Notify Plugin Broker of Router Completion
Start Routing
cont.
Plugin Broker
More Plugins with routeStartup() method?
Yes
Run Plugin’s routeStartup()
More Plugins with routeShutdown() method?
Yes
Run Plugin’s routeShutdown()
Router
Find a matching route to the current PATH_INFO
Extract Module, Controller, Action and Parameters
Inject returning values to the Request Object
Front Controller Dispatch Workflow Chart
V 1.01, Created by Polley Wong Yes Replace current Action OR Skip current action
Replace current Action
Skip current action
Front Controller
preDispatch Process
Notify Plugin Broker of Dispatch Loop Startup Request Object No Set Request Object'’s “isDispatched Flag” to TRUE Notify Plugin Broker of Dispatch Startup No Request Object More Plugins with preDispatch() method?
Yes
postDispatch Process
Action Controller Dispatch Process Notify Plugin Broker of Dispatch Completion Did any postDispatch() reset “isDispatched Flag” to FALSE? cont.
cont.
Did any preDispatch() reset “isDispatched Flag” to FALSE?
Request Object No: and Response Object
Request Object No
Plugin Broker
More Plugins with dispatchLoopStartup() method?
Yes
Run Plugin’s dispatchLoopStartup()
Yes
Run Plugin’s preDispatch()
More Plugins with postDispatch() method?
Yes
Run Plugin’s postDispatch()
Front Controller Dispatch Workflow Chart
V 1.01, Created by Polley Wong Yes Replace current Action OR Skip current action
Replace current Action
Skip current action
Front Controller
preDispatch Process
Notify Plugin Broker of Dispatch Loop Startup Request Object No Set Request Object'’s “isDispatched Flag” to TRUE Notify Plugin Broker of Dispatch Startup No Request Object More Plugins with preDispatch() method?
postDispatch Process
Yes Notify Plugin Broker of Dispatch Completion Did any preDispatch() reset “isDispatched Flag” to FALSE? Action Controller Dispatch Process Did any postDispatch() reset “isDispatched Flag” to FALSE? cont.
cont.
Request Object No: and Response Object
Request Object No
Plugin Broker
More Plugins with dispatchLoopStartup() method?
Yes
Run Plugin’s dispatchLoopStartup()
Yes
Run Plugin’s preDispatch()
More Plugins with postDispatch() method?
Yes
Run Plugin’s postDispatch()
Controller Dispatcher
FALSE Set Request Object'’s “isDispatched Flag” to TRUE Call Action Controller’s dispatch() method (Passes the Name of Action to the method)
Load Controller class file
Rretrieve Action Method Name from Request Object
Is parameter disableOutputBuffering TRUE (default) or FALSE?
TRUE
output buffer start
Is parameter disableOutputBuffering TRUE (default) or FALSE?
Append buffered content into Response Object’s TRUE body
FALSE
Destroy Action Controller Object
Action Controller
Initialize Action Helper Broker
Register Action Controller with Helper Broker No Run setActionController() method in helper
Notify Helper Broker of Dispatch Startup
Run Action Controller’s preDispatch()
Is “isDispatched Flag” == TRUE?
Call of the Action Method
Run Action Controller’s postDispatch() No
Notify Helper Broker of Dispatch Completion
Action Helper Broker
No Run init() method in helper More Helpers with preDispatch() method? More Helpers with postDispatch() method?
More helper in stack?
Yes
Yes
Run Helper’s preDispatch()
Yes
Run Helper’s postDispatch()
Front Controller Dispatch Workflow Chart
V 1.01, Created by Polley Wong Return the Response Object
Front Controller
Yes
cont.
Notify Plugin Broker of Dispatch Loop Completion
Is “returnResponse” Flag set to TRUE?
sendResponse()
Request Object No
Plugin Broker
More Plugins with dispatchLoopShutdown() method?
Yes
Run Plugin’s dispatchLoopShutdown()
postDispatch Process (cont.) Response Object
Send Headers
Output Body (echo $content)
End User’s Browser
Waiting for User Input