> [development]

should be:

[development : all]

Then we have:

$config = new Zend_Config_Ini('config.ini', 'development');
print_r($config->asArray());

Array
(
   [global] => Array
       (
           [current] => Array
               (
                   [portal] => Beta
               )

       )

   [fisch] => Array
       (
           [default] => Array
               (
                   [category] => Ontology
               )

       )

   [gans] => Array
       (
           [category] => Epistemology
       )

)

Cheers,
Gavin

Simon Mundy wrote:
Hi Horst

The Zend_Config component uses those sections to denote sections (or I think of them as 'environments') that can be selectively 'merged' and inherited and not logical groups of settings as is more commonly used in - for example - the php.ini file.

To achieve your goal, you may wish to re-write it as:-

[all]
global.current.portal = "Fisch"
fisch.default.category = "Ontology"
gans.category = "Epistemology"

[development]
global.current.portal = "Beta"


$config = new Zend_Config(new Zend_Config_Ini('./yourconfig.ini'), 'all');


The second section 'development' is used to illustrate the concept. If you loaded the config file with the keyword 'all' supplied as the second argument, your config file consists of only the first 3 directives. However if you supplied the keyword 'development' as the second argument your config would consist of the 'fisch' directive, the 'gans' directive and then your 'global' setting would be overwritten by the value in 'development'.

You then access them in your application by

$config->global->current->portal;
$config->fisch->default->category;

..etc..

Hope this helps

Hi,

I am not sure if I understand Zend_Config and it's intended use correctly.

What I need is one configuration-file per application. This configuration file is meant to be edited by the user and should allow multiple sections
possibly depending on each other.  For example

[Global]
current.portal = 'Fisch'

[Fisch]
default.category = 'Ontology'

[Gans]
default.category = 'Epistemology'


I would like to read this configuration _once_ at application startup and than be able to access the different sections. I can't see how this is easily
possible with Zend_Config.  Am I missing something?

Thanks and regards,
Horst

Reply via email to