Convert Zend_Rest_Route code to handle 2 parameters?

I have a 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 am trying to implement something like the one indicated here: http://wdvl.com/Authoring/PHP/Zend_Routes/Jason_Gilmore04282010.html

and the system responds to the url, for example:

 www.site.com/version/param1/param2 

How can I change the working code above to execute 2 parameters? I will execute other commands, such as: / retrieve /, / put / etc.

+4
source share
2 answers

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

So I always worked with routes.

+1
source

Zend_Rest_Route does not support more than one overwritten parameter (for example, / version /: id).

You will need to write your own route to handle this in the implementation of Rest.

0
source

Source: https://habr.com/ru/post/1344760/


All Articles