Obviously this is a common issue: we have PHP web applications that are managed by git or other SCMs, and are deployed (ideally) in 3+ different environments that should be extremely similar. The only differences should be in the specific configuration such as addressing of external resources (eg: database host, memcache, etc).
Here are the three methods I've seen or used:
$hosts = array ('host1.example.com' => 'production', 'staging.example.com' => 'staging' ...)
http.conf
to set an env_var: "SetEnv ENVIRONMENT dev" in your http.conf and then $environment = get_env('ENVIRONMENT');
in your scripts.Are there other methods as well? I know each of these have benefits and pitfalls--what are those?
We use Jenkins to pull from git server whenever a push event is issued.
In it's config we have a line that is different for each server:
mv config_<env>.php config.php
while config.php is in git ignore.