A few months back, our friend Ben Scholzen wrote about setting up the environment variable in your Zend Framework powered application.
With the advent of Zend Framework 1.8 and the Zend_Application component the Zend Framework Quick Start guide recommends this setting.
Handling exceptions and errors, using the same code for production, testing and staging are now easier when you define the application environment.
How do you programatically alter the value of this variable? You could write simple scripts to alter the value of the environment variable.
Solution 1: Use sed
sed -i 's/SetEnv APPLICATION_ENV development/SetEnv APPLICATION_ENV production/g' path/to/.htaccesss <path/to/.htAccess
Solution 2 Use PHP
<?php
$contents = file_get_contents('.htaccess');
$newString = str_replace("SetEnv APPLICATION_ENV development", "SetEnv APPLICATION_ENV production", $contents);
file_put_contents('.htaccess', $newString);
?>Using any of the above two snippets of code you can programatically alter the value of the environment variable from 'development' to 'production' and vice versa.