views:

856

answers:

2

Using Zend Framework I want to use controllers stored in a directory which is not default.

What I'm trying to achieve is that if the requested path begins with admin/ controllers/admin is used, with layout/admin and views/admin etc.

How would I go about achieving this in a reasonably graceful manner?

+5  A: 
$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory(...path...);

OR multiple paths

$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory(array(
    'default' => '/path/to/application/controllers',
    'blog'    => '/path/to/application/blog/controllers'
));

http://framework.zend.com/manual/en/zend.controller.front.html

glavić
I upvoted you because you're right but picked the other answer as the chosen one because I like the idea of using the modular directory structure. I did actually try doing what you said and it turns out I was just getting my paths slightly mixed up!
What I wrote and what Brian Fisher wrote is the same ;)I don't care what answer you picked, I am just glad that you solved your problem. p.s. tnx for vote up ;)
glavić
+3  A: 

You could use the module directory structure. Create the directory structure

application
  default
    controllers
    views
    models
  admin
    controllers
    views
    models

For more info check out the docs on Using a Conventional Modular Directory Structure

Brian Fisher
Hi, it would be great if this answer could somehow be merged with glavić's. I like the modular directory structure and am now using it, but his answer shows how you can let the front controller know that the modules' directory is there. Please edit to include this, I don't have enough rep!