title: Why Laravel uses wrong database file after setting environment?
body: <p>In <code>bootstrap/start.php</code> I have the following:</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>$env = $app-&gt;detectEnvironment(function()
  {
      if($myenv = getenv('APPLICATION_ENV')):
          return $myenv;
      else:
          return 'local';
      endif;
  });
  </code></pre>
  
  <p>Ok so I setup a local folder and put in a database.php file with my local connections.</p>
  
  <p>Just to make sure its picking up the correct environment I put in the template: <code>{{ App::environment(); }}</code>  which outputs <code>local</code>.</p>
  
  <p>But when making a DB call its giving me error:  <strong><code>Undefined index</code></strong><code>: DB1_HOST</code></p>
  
  <p>My base (production) <code>database.php</code> file has:</p>
  
  <pre class="lang-php prettyprint-override"><code>'host'      =&gt; $_SERVER["DB1_HOST"],
  'database'  =&gt; $_SERVER["DB1_NAME"],
  'username'  =&gt; $_SERVER["DB1_USER"],
  'password'  =&gt; $_SERVER["DB1_PASS"],
  </code></pre>
  
  <p>Why is it looking at the production database file?</p>