Pragmatism in the real world

Zend_Config: Multiple Sections and a BC Break for 0.2!

It is now possible to load multiple sections into a Zend_Config :) The inheritence mechanism in the INI files has also changed to remove it from the data space and into the section name space.

As a bonus, whilst doing them, I managed to remove a lot of rendundant code from Zend_Config_Ini and so it’s now much easier to understand how it works.

To load multiple sections just pass in an array to the $section parameter:

$config = new Zend_Config_Xml('config.xml', array('section1','section2'));

To load all sections pass in null:

$config = new Zend_Config_Xml('config.xml', null);

How easy is that ?! (Obviously this works for Zend_Config_Ini too…)

For Zend_Config_Ini users, the way to extend one section from another is to use a colon in the section name:
Previously:

[common]
db.name = 'live'


[test]
extends=common
db.name = 'test'

Now you do:

[common]
db.name = 'live'


[test : common]
db.name = 'test'

Much nicer. Note that the trunk no longer supports the old way of extending, so you must update your INI file when you upgrade to 0.2.