Zend Framework Controllers
Sunday, October 4, 2009
As discussed in the previous post, the Zend Framework breaks down a request into four parts: module, controller, action and parameters. When it has down this, it looks for the appropriate handler for the specified combination of module, controller and action.
The first thing it looks for is the appropriate controller class. Each module will have its own controllers directory. These will contain a file for each controller, named [Controller]Controller.php, e.g. IndexController.php. For the default module, these classes will be named [Controller]Controller, and for other modules [Module]_[Controller]Controller.
For instance, for the default module index controller, the class name will be IndexController, while for the admin module index controller, it will be Admin_IndexController.
The class will be derived from from Zend_Controller_Action.
If the framework cannot find an appropriately named file, or appropriately named class derived from Zend_Controller_Action, it will generate a Page Not Found error. By convention, this is handled by the error action of the error controller. This will be looked at in a later post.
If the framework manages to locate and create the class it is seeking, it will then try to find the appropriate action handler method in that class. These are public and named [action]Action, e.g. the index action handle will be called indexAction.
If the framework cannot find an appropriately named method, it will generate a Page Not Found error.
If the framework manages to locate an appropriately named method, it will execute it.
When it has executed the method, it will normally pass control to the appropriate view script for the action.
We shall look at view scripts in the next post.

Practical Web 2.0 Applications with PHP (Expert's Voice) by Quentin Zervaas
Beginning Databases with PostreSQL: From Expert to Professional 2nd Edition: From Novice to Professional by Neil Matthew, Richard Stones