zend-frameworkzend-routezend-router

Zend get route from controller


Is it possible from a controller to get the routes to all other controllers? What I need is to fetch the "/customer/:customer_id/" path.

I have scanned the controller folder so I know the names of all my controllers.

Any suggestions?


Solution

  • This solves everything!

    $router = Zend_Controller_Front::getInstance()->getRouter();
    $route =  $router->getRoute($controllerName);
    $route->getRouteUri();
    

    Posting the answer if someone else needs it.