title: Cannot read credentials from /.aws/credentials - apache vs command line on OSX local environment
body: <p>I'm experiencing problems with the AWS SKD for PHP, when attempting to create an S3 Client.</p>
  
  <p>My PHP script attempts to create the S3 Client as follows:</p>
  
  <pre><code>$client = new \Aws\S3\S3Client([
      'profile' =&gt; 'default'
      'region'  =&gt; 'eu-west-1',
      'version' =&gt; '2006-03-01',
  ]);
  </code></pre>
  
  <p>This should read my credentials file from <code>/Users/username/.aws/credentials</code>.</p>
  
  <p>It <strong>works</strong> when I run my PHP script from the command line</p>
  
  <p>It <strong>fails</strong> when I run my PHP script from within a PHP application via local apache webserver and a browser.</p>
  
  <p>The error I receive is</p>
  
  <pre><code>Cannot read credentials from /.aws/credentials
  </code></pre>
  
  <p>Notice that it's trying to read from my root directory, not my user directory.</p>
  
  <p>Having Googled this issue, several posts (like <a href="https://github.com/aws/aws-sdk-php/issues/887#issuecomment-318715019" rel="nofollow noreferrer">this one</a>) indicate that the AWS SDK makes use of the <code>$HOME</code> variable. To test this I:</p>
  
  <ul>
  <li>ran <code>printenv</code> in my terminal, which returns <code>HOME=/Users/username</code></li>
  <li>ran <code>getenv('HOME')</code> in a PHP script from the command line which returns <code>HOME=/Users/username</code></li>
  <li>ran <code>getenv('HOME')</code> and <code>print $_SERVER['HOME']</code> in a PHP script via Apache and browser - <strong>no output</strong></li>
  </ul>
  
  <p>I think the solution must be to pass <code>$HOME</code> into my apache setup - how would I achieve this?</p>