Reputation: 83697
How can I change the directory for the default module. I am using Zend Framework modular directory structure:
modules
default
controllers
IndexController.php
etc
other-module
But how can I change the directory for the default module? I would like it to be called Api. So I would have:
modules
Api
controllers
IndexController.php
other-module
I want the URIs to stay the same so:
http://localhost
Will route to modules/Api/controllers/IndexController.php and run the indexAction.
This is what I have in the bootstrap
protected function _initFrontController()
{
$front = Zend_Controller_Front::getInstance();
$front->addModuleDirectory(APPLICATION_PATH.'/modules');
return $front;
}
Upvotes: 1
Views: 201
Reputation: 14184
In application/config.ini
:
# where to find modules
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
# set the default module
resources.frontController.defaultModule = "api"
# which modules to activate
resources.modules.api = "api"
resources.moduler.other = "other"
Then you can remove the _initFrontController()
method from your Bootstrap
.
Note the character case here. Typically module names (as referenced in the config file and in routes) are lower-case. Also, the file name of the module will be lower-case (Ex: application/modules/api
). Module-specific class names (say, a controller within an admin module) will capitalize the first char of the module name as the class prefix (Ex: class Admin_ArticleController extends Zend_Controller_Action
).
[For hyphenated and camelCase module names - like your 'other-module' example - I forget precisely how module-specific classes should be prefixed, but it's easy enough to chase down if you really need it.]
Upvotes: 4
Reputation: 7954
In your config.ini
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = "default"
resources.modules[] = "api"
Your folder structure is ok
Upvotes: 1