I wanted to write a post that shows a few different ways to customise Zend Frameworks routing when you’re using their MVC implementation. Most of this is covered in the documentation, but it can be a little difficult to dig out.
The standard routing setup of Zend matches URLs like these:
1 2 | www.example.com/module/controller/action/var1/value1/var2/value2 www.example.com/controller/action/var1/value1/var2/value2 |
You set your controller directories in your bootstrap with something like:
1 2 | $front = Zend_Controller_Front::getInstance(); $front->setControllerDirectory(array('default'=>'../controllers', 'bar'=>'../modules/bar', 'foo'=>'../modules/foo')); |
For the first component of the path Zend will first look for a matching module, if none is found it will look for a matching controller. The module name ‘default’ is important here; it represents (surprisingly) the default controllers. So these are the ones when there’s no matching module in the URL.
(more…)

