ZEND - Creating custom routes without overwriting the default ones
- by Pedro Cordeiro
I'm trying to create something that looks like facebook's profile URL (http://facebook.com/username). So, at first I tried something like that:
$router->addRoute(
            'eventName',
            new Zend_Controller_Router_Route(
                '/:eventName', 
                array(
                    'module' => 'default', 
                    'controller' => 'event', 
                    'action' => 'detail'
                )
            )
        );
I kept getting the following error:
  Fatal error: Uncaught exception 'Zend_Controller_Router_Exception'
  with message 'eventName is not specified' in
  /var/desenvolvimento/padroes/zf/ZendFramework-1.12.0/library/Zend/Controller/Plugin/Broker.php
  on line 336
Not only I was unable to make that piece of code work, all my default routes were (obviously) overwritten. So I have, for example, stuff like "mydomain.com/admin", that was now returning the same error (as it fell in the same pattern as /:eventName).
What I need to do is to create this custom route, without overwriting the default ones and actually working (dûh).
I have already checked the online docs and a lot (A LOT) of stuff on google, but I didn't find anything related to the error I'm getting or how to not overwrite the default routes. I'd appreciate anything that could point me the right direction.
Thanks.