Php 更改默认模块的目录
如何更改默认模块的目录。我使用的是Zend Framework模块化目录结构:Php 更改默认模块的目录,php,zend-framework,Php,Zend Framework,如何更改默认模块的目录。我使用的是Zend Framework模块化目录结构: modules default controllers IndexController.php etc other-module 但是如何更改默认模块的目录?我希望它被称为Api。所以我会: modules Api controllers IndexController.php other
modules
default
controllers
IndexController.php
etc
other-module
但是如何更改默认模块的目录?我希望它被称为Api。所以我会:
modules
Api
controllers
IndexController.php
other-module
我希望URI保持不变,以便:
http://localhost
将路由到modules/Api/controllers/IndexController.php并运行indexAction
这就是我在引导程序中的内容
protected function _initFrontController()
{
$front = Zend_Controller_Front::getInstance();
$front->addModuleDirectory(APPLICATION_PATH.'/modules');
return $front;
}
在config.ini中
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = "default"
resources.modules[] = "api"
您的config.ini中的文件夹结构正常
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = "default"
resources.modules[] = "api"
在
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"
然后可以从引导程序中删除\u initFrontController()
方法
注意这里的字符大小写。通常,模块名称(在配置文件和路由中引用)为小写。此外,模块的文件名将采用小写形式(例如:application/modules/api
)。模块特定的类名(例如,管理模块中的控制器)将模块名的第一个字符大写为类前缀(例如:class admin\u ArticleController extensed Zend\u controller\u Action
)
[对于连字符和camelCase模块名称-就像您的“其他模块”示例一样-我完全忘记了模块特定类的前缀应该是什么,但是如果您确实需要,可以很容易地找到它。]在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"
然后可以从引导程序中删除\u initFrontController()
方法
注意这里的字符大小写。通常,模块名称(在配置文件和路由中引用)为小写。此外,模块的文件名将采用小写形式(例如:application/modules/api
)。模块特定的类名(例如,管理模块中的控制器)将模块名的第一个字符大写为类前缀(例如:class admin\u ArticleController extensed Zend\u controller\u Action
)
[对于连字符模块名和camelCase模块名,就像您的“其他模块”示例一样,我完全忘记了模块特定类的前缀,但如果您真的需要,可以很容易地找到它。]我不确定,但请在您的aplication.iniresources.frontController.moduleDirectory=APPLICATION\u PATH”/modules/api中尝试这样做
我不确定,但在aplication.iniresources.frontController.moduleDirectory=APPLICATION\u PATH”/modules/api中尝试这样做“