title: dotenv requires .env file on production
body: <p>I'm using dotenv for PHP to manage the environment settings (not lavarel but I tagged it because lavarel also uses dotenv)</p>
  
  <p>I have excluded the .env from the code base and I have added the .env.example for all other collaborators </p>
  
  <p>On the github page of dotenv: </p>
  
  <blockquote>
    <p>phpdotenv is made for development environments, and generally should not be used in production. In production, the actual environment variables should be set so that there is no overhead of loading the .env file on each request. This can be achieved via an automated deployment process with tools like Vagrant, chef, or Puppet, or can be set manually with cloud hosts like Pagodabox and Heroku.</p>
  </blockquote>
  
  <p>The thing that I don't understand is that I get the following exception:</p>
  
  <p><code>PHP Fatal error:  Uncaught exception 'InvalidArgumentException' with message 'Dotenv: Environment file .env not found or not readable.</code></p>
  
  <p>This contradicts with what documentation says "the actual environment variables should be set so that there is no overhead of loading the .env file on each request."</p>
  
  <p>So the question is if there's any reason why dotenv throws that exception and/or am I missing something? First of all the behavior is different compared to other dotenv libraries (ruby) </p>
  
  <p>I can easily work around this, the not so nice solution: </p>
  
  <pre><code>if(getenv('APPLICATION_ENV') !== 'production') { /* or staging */
      $dotenv = new Dotenv\Dotenv(__DIR__);
      $dotenv-&gt;load();
  }
  </code></pre>
  
  <p>Nicest solution in my opinion, but I think dotenv should handle this. </p>
  
  <pre><code>$dotenv = new Dotenv\Dotenv(__DIR__);
  //Check if file exists the same way as dotenv does it
  //See classes DotEnv\DotEnv and DotEnv\Loader
  //$filePath = $dotenv-&gt;getFilePath(__DIR__); 
  //This method is protected so extract code from method (see below)
  
  $filePath = rtrim(__DIR__, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR . '.env';
  //both calls are cached so (almost) no performance loss
  if(is_file($filePath) &amp;&amp; is_readable($filePath)) {
      $dotenv-&gt;load();
  }
  </code></pre>