Laravel environment variables leaking between applications when they call each other through GuzzleHttp
<p>I have two Laravel 5.2 applications (lets call them A and B) on my local machine, both configured on two different virtualhosts on my local Apache 2.4 development server.</p>

<p>Both applications sometimes are calling each other through GuzzleHttp. </p>

<p>At one point I wanted to use encryption and I started getting "mac is invalid" exceptions from Laravel's Encrypter.</p>

<p>While investigating the issue, I found that when app A calls app B, app B suddenly gets encryption key (app.key) from app A! This causes encryption to break because the values on app B where encrypted using app's B encryption key.</p>

<p>While debugging, I found the Dotenv library has some logic to keep existing variables if they are set. I found that both $_ENV and $_SERVER do not have leaked variables, but <code>getenv()</code> has them!</p>

<p>I'm a bit confused because PHP <code>putenv</code> says:</p>

<blockquote>
  <p>The environment variable will only exist for the duration of the current request.</p>
</blockquote>

<p>It seems, if during current request I launch another request through GuzzleHttp, the variables set by Dotenv in A using <code>putenv()</code> suddenly become available in app B which is being requested by GuzzleHttp!</p>

<p>I understand that this will not be an issue on production servers where config cache will be used instead of Dotenv and most probably both apps will run on different Apache servers, but this behavior is breaking my development process.</p>

<p><strong>How do I configure Laravel or GuzzleHttp or Apache or PHP to prevent this <code>putenv()</code> leakage from app A into app B?</strong></p>