All,
I have a config xml file in the following format:
<?xml version="1.0"?>
<configdata>
<development>
<siteTitle>You are doing Development</siteTitle>
</development>
<test extends="development">
<siteTitle>You are doing Testing</siteTitle>
</test>
<production extends="development">
<siteTitle>You are in Production</siteTitle>
</production>
</configdata>
To read this config file to apply environment settings, currently I am using, the following code in index.php file:
$appEnvironment = "production";
$config = new Zend_Config_Xml('/config/settings.xml', $appEnvironment );
To deploy this code on multiple environments, as user has to change index.php file. Instead of doing that, is it possible to maintain an attribute in the xml file, “say active=true”. Based on which the Zend_Config_Xml will know which section of the xml file settings to read?
If you’re using Zend Framework, I highly suggest you just use the APPLICATION_ENV constant that’s defined in Zend Application’s default index.php. If you’re not, you could probably do this regardless.
It corresponds to your the environmental variable set in your site’s
.htaccessfile:You could then load your config file like so:
Then to switch environments, all that needs to be done is switch the value in the .htaccess file. On my server, I have my deployment script set up to automatically switch the value based on which environment I’m deploying to: