Accessing variables with Zend_Rest_Route
I'm new to PHP and Zend so hopefully this is an easy one...
Simply put - how do I access an id or variable with Zend_Rest_Route?
In my开发者_Go百科 bootstrap I have
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController-getRouter();
$restRoute = new Zend_Rest_Route($frontController);
$router->(addRoute('api', $restRoute));
Typically when I set standard routes, I get the id by putting in my controller...
$router->addRoute(
'item',
new Zend_Controller_Route_Route(
'/item/:itemID',
array('controller' => 'index', 'action' => 'manipulateItem')
));
So I need to be able to access the 'id##' from localhost/api/id##
The ID parameter in REST routes is accessible as a controller parameter named id. In your controller actions e.g. like this:
$id = $this->_getParam('id');
精彩评论