Especially when in comes to switching between different working environments such as development, staging and production Apache’s enviroment variables represent a vital solution. But be advised that they do not work out of the box, as certain preconditions must be met.
First of all, you need to enable mod_env for your Apache setup. Secondly, if you are running PHP not as Apache module but rather using FastCGI you need to follow the steps provided here. Once enabled, you can easily set your enviroment variables in your httpd.conf or .htaccess file directly:
SetEnv APPLICATION_ENV development
In order to get previously set environment variables from within PHP simply use the following function:
That’s it! Pretty easy, right?