Jump to content


This topic is now archived and is closed to further replies.


Zend Admin path routing

Recommended Posts

Hello phpfreaks!  :shy:

I'm currently trying to recode my own libraries using the Zend framework. This is my problem:

By default Zend (the dispatcher?) upon access of let's say http://localhost/A/test is trying to Find an action 'testAction' in the 'A' controller.

This is fine for the public portion of my websites. However I'd like to use a different path parsing technique for the administrator interface:

I have created an AdminController which takes care of the login part. When someone authenticates I want them to be redirected to /admin/user/view and this url to be parsed as an action listAction in the UserController and not as userAction in AdminController.

Right now I'm using the redirector helper and I can forward it to the proper url with


However I'd then have to rewrite the route for each class and action inside the /admin/ path which sounds wrong.

In addition to that, by simply rerouting let's say /admin/user/view to call viewAction in UserController the url helper seems to be still outputing /user/view. I would like to fix that as well so some Controllers' urls are looked for in /admin/ instead.

Can someone advice on a clean way to solve this?  :shrug:

Share this post

Link to post
Share on other sites

I'll answer this myself for anyone interested as I've solved it and moved way past it.

In my bootstrap file I've reconfigured routing as such:


$ctrl = Zend_Controller_Front::getInstance();
$router = $ctrl->getRouter();


For the login/logout function I wanted that handled by the AdminController and actions loginAction, logoutAction so:

new Zend_Controller_Router_Route('Admin/login', array('controller'=>'Admin','action'=>'login'))
new Zend_Controller_Router_Route('Admin/logout', array('controller'=>'Admin','action'=>'logout'))


For the rest of the actions I wanted every remaining url in the admin area handled by seperate controllers. This is done like this:

new Zend_Controller_Router_Route('Admin/:controller/:action/*', array('module'=>'default'))

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.