Using application.ini for configuring Zend_Application Bootstrap
I have written custom resources for my Zend_Application bootstrap.
In the manual the following code is given for loading them:
$application = new Zend_Application(APPLICATION_ENV, array(
'pluginPaths' => array(
'My_Resource' => APPLICATION_PATH . '/resources/',
),
'resources' => array(
'FrontController' => array(
'controllerDirectory' => APPLICATION_PATH . '/controllers',
),
),
));
This however does not make use of the application.ini which I want to use. Is there a possibility to configure this completely from my application.ini?
My final solution: (with help of Will's answer):
- create an empty project wit开发者_C百科h zf.sh create project (version 1.9.6)
make the following class in 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"); } }
The following 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
Yes, you just have to use the path to your application.ini as the second argument to the constructor, e.g:
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/config/application.ini'
);
This is the approach the quick start guide takes: http://framework.zend.com/manual/en/zend.application.quick-start.html
In your .ini file you would then add resource paths like:
pluginPaths.My_Resource = APPLICATION_PATH "/resources/"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
精彩评论