-- Jonathan Maron <jonathan.a.ma...@gmail.com> wrote
(on Thursday, 28 May 2009, 11:19 AM +0200):
> For a number of reasons, I prefer to store configuration options in
> XML files and not INI files.
> 
> In "application.ini", it is possible to specify constants in the values:
> 
> [production]
> bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
> bootstrap.class = "Bootstrap"
> resources.frontController.controllerDirectory = APPLICATION_PATH 
> "/controllers"
> 
> The structure of the above in XML would be:
> 
> <production>
>       <bootstrap>
>               <path></path>
>               <class></class>
>       </bootstrap>
>       <resources>
>               <frontController>
>                       <controllerDirectory></controllerDirectory>
>               </frontController>
>       </resources>    
> </production>
> 
> How can I use constants in the XML?


At this point, you can't. It has to do with differences between how PHP
handles INI files and how it handles XML. I believe there's an issue in
the tracker already regarding this, but the solution to it looks to be
fairly tricky.


> For example, I would like to specify:
> 
> <production>
>       <bootstrap>
>               <path>APPLICATION_PATH . /Bootstrap.php</path>
>       </bootstrap>
> </production>
> 
> But this does not work. The value production->bootstrap->path is
> treated as a string:
> 
> "Warning: require_once(APPLICATION_PATH . /application/Bootstrap.php) [...]"
> 
> Similarly, I would like to set the error_reporting level:
> 
> <production>
>       <phpSettings>
>               <error_reporting>E_ALL|E_STRICT</error_reporting>
>       </phpSettings>  
> </production>
> 
> But again, the constants are treated as strings and consequently are not set.
> 
> Is it at all possible to work around these issues but still use XML to
> store application settings?
> 
> I am using Zend Framework 1.8.2 (same behavior in 1.8.1).
> 
> Thank you in advance.
> 
> Jonathan Maron
> 

-- 
Matthew Weier O'Phinney
Project Lead            | matt...@zend.com
Zend Framework          | http://framework.zend.com/

Reply via email to