[英]Zend Framework - access config file values from application.ini inside Bootstrap
I'm using Zend Framework 1.12, and I need to access a config value from application.ini inside an _initFunction from the Bootstrap. 我正在使用Zend Framework 1.12,并且需要从Bootstrap的_initFunction中访问application.ini中的配置值。
Usually, I'd do the following inside the Controller: 通常,我会在Controller内部执行以下操作:
$frontController = Zend_Controller_Front::getInstance();
$options = new Zend_Config($frontController->getParam('bootstrap')->getOptions(), true);
$language = $options->get('interface', false)->language;
However, inside the _initFunction
this does not work. 但是,在_initFunction
内部这是行不通的。
I've tried using new Zend_Config($this->getOptions(), true);
我尝试使用new Zend_Config($this->getOptions(), true);
but it does not return any data. 但它不返回任何数据。
Do you have any sollutions? 您有什么解决方案吗?
Thanks 谢谢
Here it is what might work for you: 这可能对您有用:
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
APPLICATION_PATH and APPLICATION_ENV are constants defined on index.php APPLICATION_PATH和APPLICATION_ENV是在index.php上定义的常量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.