Constant support for Zend_Config_Xml
Tuesday, July 21, 2009
Today I added support for constants in Zend_Config_Xml. This new feature will be available in Zend Framework 1.9. It was added via a Zend_Config_Xml specific XML namespace. To give you an easy example of how that may work:On PHP side, it works like usual:<config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/"><production><includePath><zf:const zf:name="APPLICATION_PATH"/>/library</includePath></production></config>
Additionally, the "extends" attribute was also moved to this new namespace, making the NULL namespaced extends attribute deprecated until ZF 2.0, when it will be removed.<?phpdefine('APPLICATION_PATH',dirname(__FILE__));$config=newZend_Config_Xml($xmlString,'production');echo$config->includePath;// Prints "/var/www/something/library"
Comments to this article
Leave a comment
Please note that your email address will not be shown, it is only used to fetch your avatar image from gravatar.com and to contact you in case.


Nice one! Does this also work for class constants like Foo::BAR?
Nope, that only works for usual PHP constants, as in .ini config files.
thank ben. it's usefull method.
It's good tools. but for first code of bootstrap not good because XML file have so time for pars and need cache before use.
But this way is useful.