<legend id='gImdr'><style id='gImdr'><dir id='gImdr'><q id='gImdr'></q></dir></style></legend>
          <bdo id='gImdr'></bdo><ul id='gImdr'></ul>

      1. <tfoot id='gImdr'></tfoot>
      2. <small id='gImdr'></small><noframes id='gImdr'>

        <i id='gImdr'><tr id='gImdr'><dt id='gImdr'><q id='gImdr'><span id='gImdr'><b id='gImdr'><form id='gImdr'><ins id='gImdr'></ins><ul id='gImdr'></ul><sub id='gImdr'></sub></form><legend id='gImdr'></legend><bdo id='gImdr'><pre id='gImdr'><center id='gImdr'></center></pre></bdo></b><th id='gImdr'></th></span></q></dt></tr></i><div id='gImdr'><tfoot id='gImdr'></tfoot><dl id='gImdr'><fieldset id='gImdr'></fieldset></dl></div>

      3. 如何设置分层 Zend 休息路线?

        How to set up Hierarchical Zend Rest Routes?(如何设置分层 Zend 休息路线?)
      4. <small id='zEVEZ'></small><noframes id='zEVEZ'>

          <tbody id='zEVEZ'></tbody>
        1. <tfoot id='zEVEZ'></tfoot>
          • <bdo id='zEVEZ'></bdo><ul id='zEVEZ'></ul>
                <legend id='zEVEZ'><style id='zEVEZ'><dir id='zEVEZ'><q id='zEVEZ'></q></dir></style></legend>
                • <i id='zEVEZ'><tr id='zEVEZ'><dt id='zEVEZ'><q id='zEVEZ'><span id='zEVEZ'><b id='zEVEZ'><form id='zEVEZ'><ins id='zEVEZ'></ins><ul id='zEVEZ'></ul><sub id='zEVEZ'></sub></form><legend id='zEVEZ'></legend><bdo id='zEVEZ'><pre id='zEVEZ'><center id='zEVEZ'></center></pre></bdo></b><th id='zEVEZ'></th></span></q></dt></tr></i><div id='zEVEZ'><tfoot id='zEVEZ'></tfoot><dl id='zEVEZ'><fieldset id='zEVEZ'></fieldset></dl></div>

                  本文介绍了如何设置分层 Zend 休息路线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 Zend 框架,我尝试在按以下模式组织的资源上为 REST api 构建路由:

                  • http://example.org/users/
                  • http://example.org/users/234
                  • http://example.org/users/234/items
                  • http://example.org/users/234/items/34

                  我如何使用 Zend_Rest_Route 进行设置?

                  这是我在 bootstrap.php 文件中为用户资源 (users/:id) 设置路由的方法:

                   $this->bootstrap('frontController');$frontController = Zend_Controller_Front::getInstance();$restRoute = new Zend_Rest_Route($frontController);$frontController->getRouter()->addRoute('default', $restRoute);

                  [据我所知,这是一个包罗万象的路线,因此 users/324/items/34 将导致参数设置为 id=324 和 items=34,并且所有内容都将映射到用户(前端模块)模型.从那里我想我可以只测试 items 参数并在 get 请求中为用户 #324 检索项目 #34.]<=== 我刚刚检查了它,它似乎不是这样工作的:

                  访问/users/234/items/43 和

                  var_dump($this->_getAllParams());

                  在其余控制器的 get 操作中产生以下输出:

                  array(4) {[控制器"]=>字符串(5)用户"[动作"]=>字符串(3)获取"[2]=>string(5) "items" ["module"]=>字符串(7)默认"]}

                  不知何故,两个 ID 都丢失了...

                  有人吗?

                  解决方案

                  AFAIK,Zend_Rest_Route 中没有允许您执行此类操作的功能.有一个提案,但不确定何时实施.您可以将其添加到 Bootstrap 中以设置此自定义路由.

                  $front = $this->getResource('FrontController');$testRoute = new Zend_Controller_Router_Route('users/:user_id/items/:item_id',大批('控制器' =>'用户','动作' =>'物品','模块' =>'默认'));$front->getRouter()->addRoute('test', $testRoute);

                  user_iditem_id 在 UsersController 的 itemAction 中作为参数可用:

                  $user_id = $this->_request->getParam('user_id');

                  With the Zend Framework, I am trying to build routes for a REST api on resources organized in the following pattern:

                  • http://example.org/users/
                  • http://example.org/users/234
                  • http://example.org/users/234/items
                  • http://example.org/users/234/items/34

                  How do I set up this with Zend_Rest_Route?

                  Here is how I have setup the route for the users resource (users/:id) in my bootstrap.php file:

                    $this->bootstrap('frontController');
                    $frontController = Zend_Controller_Front::getInstance();
                    $restRoute = new Zend_Rest_Route($frontController);
                    $frontController->getRouter()->addRoute('default', $restRoute);
                  

                  [As far as I understand, this is a catch all route so users/324/items/34 would results in parameters set as id=324 and items=34 and everything would be mapped to the Users (front module) Model. From there I guess I could just test for the items parameter and retrieve the item #34 for user #324 on a get request.]<=== I just checked it and it doesn't seems to work like that:

                  Acessing /users/234/items/43 and

                  var_dump($this->_getAllParams());
                  

                  in the get action of the rest controller results in the following output:

                  array(4) {
                   ["controller"]=> string(5) "users"
                   ["action"]=>  string(3) "get"
                   [2]=>  string(5) "items"  ["module"]=>  string(7) "default"]
                  }
                  

                  Somehow both ids got lost...

                  Anyone?

                  解决方案

                  AFAIK, there is no feature in Zend_Rest_Route which allows you to do something like this. There is a proposal but not sure when it'll be implemented. You can add this in your Bootstrap to set up this custom route.

                  $front = $this->getResource('FrontController'); 
                  $testRoute = new Zend_Controller_Router_Route(
                      'users/:user_id/items/:item_id',
                      array(
                          'controller' => 'users',
                          'action' => 'item',
                          'module' => 'default'
                      )
                  );
                  
                  $front->getRouter()->addRoute('test', $testRoute);
                  

                  user_id or item_id become available in itemAction in UsersController as parameters:

                  $user_id = $this->_request->getParam('user_id');
                  

                  这篇关于如何设置分层 Zend 休息路线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <tbody id='2WLxy'></tbody>
                  <legend id='2WLxy'><style id='2WLxy'><dir id='2WLxy'><q id='2WLxy'></q></dir></style></legend>
                    <tfoot id='2WLxy'></tfoot>
                    1. <i id='2WLxy'><tr id='2WLxy'><dt id='2WLxy'><q id='2WLxy'><span id='2WLxy'><b id='2WLxy'><form id='2WLxy'><ins id='2WLxy'></ins><ul id='2WLxy'></ul><sub id='2WLxy'></sub></form><legend id='2WLxy'></legend><bdo id='2WLxy'><pre id='2WLxy'><center id='2WLxy'></center></pre></bdo></b><th id='2WLxy'></th></span></q></dt></tr></i><div id='2WLxy'><tfoot id='2WLxy'></tfoot><dl id='2WLxy'><fieldset id='2WLxy'></fieldset></dl></div>
                      • <bdo id='2WLxy'></bdo><ul id='2WLxy'></ul>

                      • <small id='2WLxy'></small><noframes id='2WLxy'>