Zend Framework Dispatch Workflow (v1.01)

  • 18,609 views
Uploaded on

I've been researching Zend Framework lately and was curious about what's actually happening behind the scene of the whole dispatch process. I found a wonderful diagram created by Thorsten Ruf …

I've been researching Zend Framework lately and was curious about what's actually happening behind the scene of the whole dispatch process. I found a wonderful diagram created by Thorsten Ruf (http://nethands.de/download/zenddispatch_en.pdf)

Inspired by it's clear and beautifully presented workflow, I decided to go a step deeper and crawl Zend Framework's code. I came up with my own version of the flexible yet complicated workflow. The Zend Framework version is 1.7, noting that things might have changed a bit in the latest 1.8 version that was released a weeks ago.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
18,609
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
1,118
Comments
2
Likes
25

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

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