Zend Framework 0.2
31st October 2006Version 0.2 of the Zend Framework has been released. I'll be updating my tutorial shortly - as soon as I have some spare time!
Version 0.2 of the Zend Framework has been released. I'll be updating my tutorial shortly - as soon as I have some spare time!
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.
A week or so ago, I got a chance to sit down (on IM) with Darby and look at the outstanding issues for Zend_Config. We went through the all open issues and the items on the wiki page to ensure we knew what was intended for 0.2. As a result, I filed a few issues with the issue tracker to enhance Zend_Config and note possible bugs.
Essentially, the enhancements are:
Between them, we'll be enhancing Zend_Config's power without making it any harder to use.
This weekend, I got a chance to look at ZF-352 and promptly found two new bugs!
ZF-425 (extends= line must be first in the [section]) is a classic case of unit tests not protecting you from yourself! There are quite a few unit tests for Zend_Config, but none of them ever exercise the case where the "extends" data key is not the first key in a section. This is because I wrote it and it never occurred to me :)
ZF-426 (Setting a key as a scalar and an array fails) is a case where the unit tests don't cover the all code paths. Thus code in the class that was supposed to handle this case clearly didn't! Whilst looking at this bug, it crossed my mind that there were two functions in Zend_Config_Ini that did essentially the same thing. So much so, that I couldn't work out the difference between them! As a result I removed one of the functions whilst fixing ZF-426 and now Zend_Config_Ini is now that much easier to understand :)
Incidentally, there's a patch attached to ZF-352, if anyone fancies reviewing it…