php – 转换Zend_Rest_Route代码来处理2个参数?
作者:互联网
我有来自http://www.chrisdanielson.com/2009/09/02/creating-a-php-rest-api-using-the-zend-framework/的Zend代码,如下所示:
$this->bootstrap('Request');
$front = $this->getResource('FrontController');
$restRoute = new Zend_Rest_Route($front, array(), array(
'default' => array('version')
));
$front->getRouter()->addRoute('rest', $restRoute);
我正在试图像这里指定的那样:http://wdvl.com/Authoring/PHP/Zend_Routes/Jason_Gilmore04282010.html
并让系统响应网址,例如:
www.site.com/version/param1/param2
如何更改上面的工作代码来做2个参数?我将实现其他命令,例如:/ retrieve /,/ put /等.
解决方法:
我的Bootstrap中的路由如下:
/*
* ReWrite Rules and Routes
*/
protected function _initRoutes() {
$router = Zend_Controller_Front::getInstance ()->getRouter ();
$router->addRoute('rest_url', new Zend_Controller_Router_Route('version/:param1/:param2/', array( 'module'=>'ModuleName', 'controller' => 'ControllerName', 'action' => 'ActionName', 'param1' => 'default here if you want', 'param2' => 'can leave param1 and param2 blank here')));
}
这是我一直有路线工作的方式.
标签:php,zend-framework,zend-route 来源: https://codeday.me/bug/20190710/1420266.html