I was reading this to understand zend’s MVC Request Lifecycle.
But i can’t think of any cases in zend where i would use a controller’s predispatch method , isn’t the init method enough for the code that i want executed before controller’s actions .
What should exactly should be in a controller’s predispatch and not init .
Can you give an example ?
See Zend_Controller_Action – Object Initialization and the following section Pre and Post Dispatch Hooks. They both go into some detail on the two, and the Action Controller itself.
init()is more for setting up the controller object and doing initialization that will be available to all of your actions. Sinceinit()runs prior topreDispatch(), anything you set up ininit()will be available forpreDispatch()to use. While it is possible to forward or redirect frominit(), it is best practice to do it frompreDispatch()because it runs prior to dispatching the controller action.From the manual: