If you’re working in a setup where production machines and development machines are doing slightly different thing (DB connection details, debugging, etc…) then you’ll likely need so way to set a variable to determine which environment the application is in. To keep it out of the application code itself and out of repositories, I’ve always preferred setting an environment variable in Apache’s httpd.conf and accessing it through PHP. Here’s how that’s done.
Open your production httpd.conf and add a line following the example below. This will set the flag. Note that this can also be done in the .htaccess file to get the same effect.
SetEnv HTTP_CODE_ENV "production"
You can do the same in your development environment (or, even safer than this is to default to production settings and only set this in development).
SetEnv HTTP_CODE_ENV "development"
Now, to access this in PHP, just use the following snippet early in your call stack (the bootstrap, for example).
From this point forward, you can access the string from httpd.conf anywhere in PHP as the constant defined above.