4

I have Zend code from http://www.chrisdanielson.com/2009/09/02/creating-a-php-rest-api-using-the-zend-framework/ which looks like this:

    $this->bootstrap('Request');
    $front = $this->getResource('FrontController');
    $restRoute = new Zend_Rest_Route($front, array(), array(
        'default' => array('version')
    ));
    $front->getRouter()->addRoute('rest', $restRoute);

I'm trying to implment something like as specified here: http://wdvl.com/Authoring/PHP/Zend_Routes/Jason_Gilmore04282010.html

and have the system respond on a url such as:

www.site.com/version/param1/param2

How can I change the working code above to do 2 params? I WILL be implementing other commands such as: /retrieve/, /put/, etc.

Charles
  • 50,943
  • 13
  • 104
  • 142
siliconpi
  • 8,105
  • 18
  • 69
  • 107

2 Answers2

1

Routes in my Bootstrap are as follows:

    /*
     * 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')));
    }

This is the way I've always had routes working.

bluedaniel
  • 2,079
  • 5
  • 31
  • 49
0

Zend_Rest_Route does not support more than one rewritten parameter (e.g. /version/:id).

You'll have to write a custom route to handle this in your Rest implementation.

SubOne
  • 613
  • 5
  • 19