I am creating a web service with zend and I use modules to separate my api versions. Example: "applications / modules / v1 / controllers", "applications / modules / v2 / controllers" have a different set of actions and functionality.
I made "v1" as the default module in the file "application.ini":
resources.modules = "" resources.frontController.defaultModule = "v1" resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.frontController.moduleControllerDirectoryName = "controllers"
In my boot file, I wrote the following:
$router = $front->getRouter(); $r1 = new Zend_Controller_Router_Route_Regex('api/v1/tags.xml', array('module' => 'v1', 'controller' => 'tags', 'action' => 'index')); $router->addRoute('route1', $r1);
Suppose if this is my url: http://localhost/api/v1/tags.xml
then it belongs to version 1 (v1).
But I donβt want to write a lot of routes like this, so I want to know how I can track the version from urge regex and dynamically determine the version of api that will be used (1 or 2).
php zend-framework
shasi kanth
source share