Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 642853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:13:08+00:00 2026-05-13T21:13:08+00:00

With the Zend Framework, I am trying to build routes for a REST api

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:13:09+00:00Added an answer on May 13, 2026 at 9:13 pm

    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');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to store custom routes for the Zend Framework inside the database.
The Zend Framework coding standard mentions the following: For files that contain only PHP
I am trying to develop websites using Zend Framework. But I came to a
I am trying to get Zend Framework's quickstart tutorial up and running, but i
hello I am using zend framework and i am trying to combine it with
I'm trying to connect to a mssql db with the Zend Framework, my application.ini
I am trying to create a dynamic sidebar in zend framework. I have googled
The Zend Framework based site I have been working on is now being migrated
I have a Zend Framework application structure as below: /application /library /Zend /Core /Filter
I am using the Zend Framework. I have a controller named 'UserController' that has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.