title: What methods are used for differentiating between production/staging/development environments in PHP applications?
body: <p>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).</p>
  
  <p>Here are the three methods I've seen or used:</p>
  
  <ol>
  <li>Maintain an array of hostnames => environment types:
  <code>$hosts = array ('host1.example.com' =&gt; 'production', 'staging.example.com' =&gt; 'staging' ...)</code></li>
  <li>Have a config file that is in the .gitignore (or equivalent for other SCMs) with an example version to copy and edit</li>
  <li>Use <code>http.conf</code> to set an env_var: "SetEnv ENVIRONMENT dev" in your http.conf and then <code>$environment = get_env('ENVIRONMENT');</code> in your scripts.</li>
  </ol>
  
  <p>Are there other methods as well? I know each of these have benefits and pitfalls--what are those?</p>