I have a module based zend application. I am trying to route modules appropriately, based on a version number (param) defined, ie. domain.com/api/v1.
my app looks like this
-application
...
--modules
----default
----api
----api2
...
I have a router in my bootstrap routing correctly, but to a default module, 'api'.
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$route = new Zend_Controller_Router_Route(
'api/:apiversion/:controller/:action/*',
array('module' => 'api',
'apiversion' => ':apiversion',
'controller' => ':controller',
'action' => ':action')
);
$router->addRoute('api', $route);
How can i route based on the apiversion param, 'v1', 'v2'?
domain.com/api/v2/users/id/5 => /api2/users/id/5
-Yes i understand I can have the user input domain.com/api2/ ... -not what i want.
-Yes i understand I can have the user input domain.com/api/version/2 ... -not what i want.
I will only do those if what I want can't be achieved. Thank you :)
I figure I can do a ->getParam("v1") to see if it exists, then set the appropriate module, unless there is a pretty, dynamic way