我已经为Zend_Application bootstrap编写了自定义资源。
在the manual中,以下代码用于加载它们:
$application = new Zend_Application(APPLICATION_ENV, array(
'pluginPaths' => array(
'My_Resource' => APPLICATION_PATH . '/resources/',
),
'resources' => array(
'FrontController' => array(
'controllerDirectory' => APPLICATION_PATH . '/controllers',
),
),
));
然而,这并没有使用我想要使用的application.ini。是否有可能从我的application.ini中完全配置它?
我的最终解决方案:(在Will的回答的帮助下):
在application / resources / Ftp.php中创建以下类
class My_Resource_Ftp extends Zend_Application_Resource_ResourceAbstract
{
protected $_params = array();
public function init() {
echo "init invoked";
return array("hey");
}
}
以下application.ini
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
pluginPaths.My_Resource = APPLICATION_PATH "/resources/"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.ftp.username = "me"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
答案 0 :(得分:1)
是的,您只需使用application.ini的路径作为构造函数的第二个参数,例如:
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/config/application.ini'
);
这是快速入门指南采用的方法:http://framework.zend.com/manual/en/zend.application.quick-start.html
在.ini文件中,您将添加资源路径,如:
pluginPaths.My_Resource = APPLICATION_PATH "/resources/"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"