Zend_Rest_Route not working for a sub-directory controller

I'm trying to define RESTful routes for sub directory controllers. I want to be able to create routes for the url at admin/questions/*. My controller is Admin_QuestionsController:

- application
  - controllers
      QuestionsController.php (class Admin_QuestionsController)

Below is how I'm declaring my RESTful route for this controller:

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

..from the documentation I can't see what I'm doing wrong -http://framework.zend.com/manual/1.12/en/zend.controller.router.html#zend.controller.router.routes.rest. However, I get the following error:

Invalid controller specified (admin) 

I can get the routes to work when I declare then not as Rest routes:

    new Zend_Controller_Router_Route( '/admin/questions', array(
        'controller' => 'Admin_Questions', 
        'action' => 'index')

..so I don't think I've have the folder structure wrong, or the class name. But, I need RESTful routes which I'm unable to achieve.

asked May 16, 2015 in Zend by rajesh
0 votes

1 Answer

0 votes
The Zend_Rest_Route route like you have defined, works if you have Zend modules enabled. The documentation mentions "translating the HTTP method and the URI to a module, controller and action". To enable modules, add the following two lines in your application.ini:

resources.modules[] =
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
Then create a directory in application/modules named admin/controllers, and create your QuestionsController in application/modules/admin/controllers/QuestionsController.php.

The rest of your application should (hopefully) still work as the default module.
answered May 16, 2015 by rajesh