Hi,
 
Try this .... this also allows for you to have a development version of the 
.ini file as well so you don't have to touch the production version:
 
$localConfigName = APPLICATION_PATH . '/config/dev.ini';
 
$config = new Zend_Config_Ini(APPLICATION_PATH . '/config/app.ini', null, true);
 
if (is_file($localConfigName)) {
    $localConfig = new Zend_Config_Ini($localConfigName, null, true);
    $config->merge($localConfig);
}
 
$config->setReadOnly();
 
/**
 * Define PHP ini settings
 * These can be removed for a release version!
 */
ini_set('log_errors', (bool) $config->general->debug);
ini_set('display_errors', (bool) $config->general->debug);

 
$registry = Zend_Registry::getInstance();
$registry->config = $config;

 
You can then easily get access to the config by using:
 
 
Zend_Registry::get('config')->general->myVar
 
- Robert

________________________________

From: vadim gavrilov [mailto:vadim...@gmail.com] 
Sent: 04 March 2009 08:57
To: Gregory Eve
Cc: Zend Framework - General
Subject: Re: [fw-general] Loading a config.ini file


Something like this?

$config = new Zend_Config_Ini(APPLICATION_PATH . '/config.ini');
$registry = new Zend_Registry(array('config' => $config));

and then:

$registry = Zend_Registry::getInstance();

        var_dump( $registry['config'] );
outputs nothing.


On Wed, Mar 4, 2009 at 10:51 AM, Gregory Eve <gregory....@mimesis-republic.com> 
wrote:


        Hi,
        
        you need to put your Zend_Config object in the Zend_Registry to access 
to it in your entire application.
        
        
        Grégory EVE
        developer engineer
        PlayBack Team
        
        Mimesis Republic
        80, rue des Haies
        75020 Paris
        




-- 
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.






________________________________________________________________________
This email has been scanned for all known viruses by the MessageLabs Email 
Security Service and the Macro 4 plc internal virus protection system.
________________________________________________________________________


________________________________________________________________________
This email has been scanned for all known viruses by the MessageLabs Email 
Security Service and the Macro 4 plc internal virus protection system.
________________________________________________________________________

Reply via email to