我正在开发一个 Zend Framework (1.11) 应用程序,我正在将其移植到模块中,以便开发人员可以即插即用我们软件中的各种添加内容,并轻松删除。
我遇到的问题(似乎无法找到答案)我有可靠的库代码,即我的结构目前是这样的
- application
- (the standard ZF stuff)
- modules
- testModule
- Bootstrap.php
- controllers
- configs
- views
- library
- CoreStuff
- Class.php
- SpecialClass.php
- testModuleLibrary
- Class.php
- SpecialClass.php
我真正想要的是这样其他开发人员可以更轻松地将模块安装到我们的系统中。
- application
- (the standard ZF stuff)
- modules
- testModule
- Bootstrap.php
- controllers
- configs
- views
- library
- Class.php
- SpecialClass.php
- library
- CoreStuff
- Class.php
- SpecialClass.php
我可以在 Bootstrap 模块中使用 Autoloader 吗?或者我必须将其添加到我的包含路径中吗?
[编辑]
这是我当前的模块 Bootstrap ,我通过危险的谷歌搜索一次又一次地看到了这段代码,但它似乎没有任何区别
<?php
class Notifications_Bootstrap extends Zend_Application_Module_Bootstrap {
protected function _initLibraryAutoloader () {
return $this->getResourceLoader()->addResourceType('library', 'library', 'library');
}
}
最佳答案
我已经使用以下代码解决了我的问题。我真的不知道为什么我没有早点想到这个:( :(
class Notifications_Bootstrap extends Zend_Application_Module_Bootstrap {
protected function _initConfig () {
set_include_path(implode(PATH_SEPARATOR, array(
dirname(__FILE__) . '/library',
get_include_path(),
)));
}
}
关于php - Zend框架模块库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13377983/