简体   繁体   中英

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.

Usually, I'd do the following inside the 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.

I've tried using 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM