2012-01-31 159 views
1

如何更改默认模块的目录。我使用Zend框架模块目录结构:更改默认模块的目录

modules 
    default 
     controllers 
      IndexController.php 
     etc 
    other-module 

但我怎么能更改默认模块目录?我希望它被称为Api。因此,我将有:

modules 
    Api 
     controllers 
      IndexController.php 
    other-module 

我想要的URI保持不变如此:

http://localhost 

将路由到模块/原料药/控制器/ IndexController.php和运行的indexAction。

这是我在引导

protected function _initFrontController() 
{ 
    $front = Zend_Controller_Front::getInstance(); 
    $front->addModuleDirectory(APPLICATION_PATH.'/modules'); 
    return $front; 
} 
+0

我不确定,但在你的apllication.ini'resources.frontController.moduleDirectory = APPLICATION_PATH“/ modules/api” – Rikesh 2012-01-31 11:15:26

回答

4

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" 

然后,您可以从Bootstrap中删除_initFrontController()方法。

请注意这里的字符大小写。通常,模块名称(如配置文件和路径中引用的)是小写字母。此外,模块的文件名称将为小写(例如:application/modules/api)。特定于模块的类名(例如,管理模块中的控制器)将大写模块名的第一个字符作为类前缀(例如:class Admin_ArticleController extends Zend_Controller_Action)。

[对于复姓和驼峰模块名称 - 喜欢你“其他模块”的例子 - 我忘了具体的模块类应如何准确为前缀,但它很容易追下去,如果你真的需要它]

1

在你的config.ini

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" 
resources.modules[] = "default" 
resources.modules[] = "api" 

你的文件夹结构是确定