Skip to content

Instantly share code, notes, and snippets.

Created May 18, 2011 18:14
Show Gist options
  • Save anonymous/979156 to your computer and use it in GitHub Desktop.
Save anonymous/979156 to your computer and use it in GitHub Desktop.
Zend_Rest_Route Chain Route so that the URL looks like example.com/api/v1/:controller
$this->bootstrap('frontController');
$frontController = Zend_Controller_Front::getInstance();
$apiVersionRoute = new Zend_Controller_Router_Route(
'api/:version/',
array(),
array('version' => 'v\d+')
);
$restRoute = new Zend_Rest_Route(
$frontController,
array('module' => 'api'),
array('api' => array(
'test'
))
);
$chainedRoute = new Zend_Controller_Router_Route_Chain();
$chainedRoute->chain($apiVersionRoute)->chain($restRoute);
$frontController->getRouter()->addRoute('rest', $chainedRoute);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment