ZF-11327: Improvement for Zend_Rest_Route

Issue Type: Improvement Created: 2011-04-26T23:41:29.000+0000 Last Updated: 2012-11-21T08:08:28.000+0000 Status: Open Fix version(s): Reporter: Jonathan Cardoso Machado (jcmais) Assignee: Luke Crouch (lcrouch) Tags: - Zend_Rest_Route

Related issues: Attachments:


Today, developing the API (that is similar to Facebook Graph API) for a personal project, I ran into a limitation of the routes taken by Zend_Rest_Route. The limitation is that if I access a url like that:…

The id becomes a parameter with value resource, and that's not what I want, and I also guess it's not what other people want, therefore, with the modification that I made, the behaviors possible for the Zend_Rest_Route increases, and is as follows:

{quote} ||Method||URI||Module_Controller::action Default Behavior: |GET|/api/users/|Api_UsersController::indexAction() |GET|/api/users/:id|Api_UsersController::getAction() |POST|/api/users|Api_UsersController::postAction() |PUT|/api/users/:id|Api_UsersController::putAction() |DELETE|/api/users/:id|Api_UsersController::deleteAction() |POST|/api/users/:id?_method=PUT|Api_UsersController::putAction() |POST|/api/users/:id?_method=DELETE|Api_UsersController::deleteAction()

What I've added: |METHOD|/api/users/:id/:resource|Api_UsersController::methodAction() |METHOD|/api/users/:id/:resource/:subresource|Api_UsersController::methodAction() {quote}

<pre class="highlight">
elseif (($pathElementCount == 3 || $pathElementCount == 2) && !isset($params['id'])){
    $params['id'] = $path[0];
    $params['resource'] = $path[1]; unset($path[1]);
        $params['subResource'] = $path[2]; unset($path[2]);

I hope it is useful to someone, I do not know if what I did is totally correct, but the way it was, I could not get a request like this in my API:


Posted by Luke Crouch (lcrouch) on 2011-04-27T14:07:28.000+0000

In my ZF apps I would have put the "User 12345's friends" resource at:

Which would go to FriendsController::indexAction() with user=>12345.

Sub-resource url's are a great idea, though, and I think we should try to implement them in Zend_Rest 2.0 with ZF 2.0 orm.

Posted by Jonathan Cardoso Machado (jcmais) on 2011-04-27T17:22:54.000+0000

Yep, but I did not want this index in the url. :)

Posted by Luke Crouch (lcrouch) on 2011-04-28T15:14:55.000+0000

Sure. I'm basically in a holding pattern on the Zend_Rest stuff until ZF 2.0 MVC is released. So, I'll probably just leave this issue here for triage post-2.0.

Posted by nike shox (nike shox) on 2012-11-21T08:08:28.000+0000

without tvil Nike Skateboarding is classic silhuetten get a Woodgrain makeover with this Quickstrike utgivelsen surface on skate butikker this month. Den popular Stefan Janoski pro-Modellen has a tonal brun Øvre with skinn detaljering on the Indre liner, Varme and Blonder.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.