加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 转换Zend_Rest_Route代码来处理2个参数?

发布时间:2020-12-13 22:30:02 所属栏目:PHP教程 来源:网络整理
导读:我有来自 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,arr
我有来自 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')));
    }

这是我一直有路线工作的方式.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读