Web App Development - Systems Architecture - API Building - Security Audits

Posts Tagged ‘Zend Framework’

Customising Zend Framework Routing

Monday, March 9th, 2009

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…)

About this blog

We like to blog about things we're passionate about. We love PHP, MySQL, CouchDB, Linux, Apache - web development standards. We also like writing about building web apps and working with web technology.
You can email us on freedom@echolibre.com

Follow us on Twitter

Eamon Leonard - @EamonLeonard
David Coallier - @DavidCoallier
Helgi Þormar Þorbjörnsson - @h
J.D Fitz.Gerald - @jdfitzgerald
Noah Slater - @nslater
Court Ewing - @courtewing

 

 

 

echolibre limited is registered in Ireland, company number 451576. Directors: Eamon Leonard, J.D Fitz.Gerald. Registered Office: 64 Dame Street, Dublin 2, Ireland.