title: How to let Cakephp 3 choose database connection by Apache environment variable
body: <p>I'm working with cakephp v3 and want to install the application in two different environments, one for development and one for production use.  Both installations should consist of exactly the same files (and file contents), so I could use 'git' or 'svn' to easily deploy the application.  </p>
  
  <p>If both environments are hosted on the same machine, I need different database settings (so that the development env uses its own 'testing' DB).  I thought of configuring two 'Datasources' in <code>app.php</code>, the 'default' one for production and a `development'.  </p>
  
  <p>But how can I switch between both sources?  </p>
  
  <p>To be more specific: Currently I define the following environment variable in my Apache config for the development environment:</p>
  
  <pre><code>SetEnv CAKEPHP_DEBUG 1
  </code></pre>
  
  <p>Then I changed the definition of 'debug' in the <code>app.php</code> file like this:</p>
  
  <pre><code>'debug' =&gt; (bool)getenv('CAKEPHP_DEBUG'),
  </code></pre>
  
  <p>This enables DEBUG mode only on the development machine.  Now I also want to switch database configuration in the same easy way.</p>
  
  <p>(I already found some solutions for cakephp v2, but all of them are pretty old and I'm not sure what's the best way to do it in cakephp v3.)</p>