Zend Framework - How do make a hierarchy without it being a module?

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2010-02-01T00:03:05Z Indexed on 2010/03/13 23:55 UTC
Read the original article Hit count: 168

Filed under:
|
|
|

Here is my specific issue. I want to make an api level which then under that you can select which method you will use. For example:

test.com/api/rest

test.com/api/xmlprc

Currently I have api mapping to a module directory. I then setup a route to make it a rest route. test.com/api is a rest route, but I would rather have it be test.com/api/rest. This would allow me later to add others.

In Bootstrap.php:

        $front = Zend_Controller_Front::getInstance();
  $router = $front->getRouter();
    $route = new Zend_Controller_Router_Route(
 'api/:module/:controller/:id/*',
 array('module' =>'default')

);

$router->addRoute('api', $route);

$restRoute = new Zend_Rest_Route($front, array(), array( 'rest' )); $router->addRoute('rest', $restRoute);

return $router;

In application.ini:

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

I know it will involve routes, but sometimes I find the Zend Framework documentation to be a little hard to follow.

When I go to test.com/rest/controller/ it works how it should, but if I go to test.com/api/rest/ it tells me that my module is api and controller is rest.

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about php