How to get Zend_Config used by Zend_Application?

I am porting my application to use Zend_Application for bootstrapping. I used to have Zend_Config as the key for my $ registry.

Now I do not know how to use it that way (without the need to reload the configuration file). I know that you can use $ application-> getOptions (), but this gives me an array, and I have to change everywhere in my code where $ config is used as an object ($ config-> services-> storage) for the -like ( $ config ['services'] ['storage']).

+3
source share
2 answers
Zend_Registry::set('config', new Zend_Config($this->getOptions()));

- thatโ€™s all you need.

+4
source

Zend_Application ( ) config.ini, 'new Zend_Application(ENV, '.../app.ini');' . , .

bootstrap, , ,

<?php
// in 'class Bootstrap extends Zend_Application_Bootstrap_Bootstrap'

protected function _initConfig()
{
    // config
    //#Zend_Registry::set('config', $this->getOptions());  // as an array

    $ZFOptions      = array(); // could be: 'allowModifications'=>true
    $section        = 'production';  // or from the environment
    $configFilename = APPLICATION_PATH .'/configs/application.ini';
    $config = new Zend_Config_Ini($configFilename, $section, $ZFOptions);
    Zend_Registry::set('config', $config);  // as an object
}
+2

Source: https://habr.com/ru/post/1720396/


All Articles