{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/8187","labels_url":"https://api.github.com/repos/laravel/framework/issues/8187/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/8187/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/8187/events","html_url":"https://github.com/laravel/framework/pull/8187","id":64640265,"number":8187,"title":"replacing getenv($key) with array_get($_ENV, $key)","user":{"login":"janhartigan","id":580052,"avatar_url":"https://avatars.githubusercontent.com/u/580052?v=3","gravatar_id":"","url":"https://api.github.com/users/janhartigan","html_url":"https://github.com/janhartigan","followers_url":"https://api.github.com/users/janhartigan/followers","following_url":"https://api.github.com/users/janhartigan/following{/other_user}","gists_url":"https://api.github.com/users/janhartigan/gists{/gist_id}","starred_url":"https://api.github.com/users/janhartigan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janhartigan/subscriptions","organizations_url":"https://api.github.com/users/janhartigan/orgs","repos_url":"https://api.github.com/users/janhartigan/repos","events_url":"https://api.github.com/users/janhartigan/events{/privacy}","received_events_url":"https://api.github.com/users/janhartigan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-26T21:39:11Z","updated_at":"2015-03-27T02:34:19Z","closed_at":"2015-03-26T22:55:21Z","pull_request":{"url":"https://api.github.com/repos/laravel/framework/pulls/8187","html_url":"https://github.com/laravel/framework/pull/8187","diff_url":"https://github.com/laravel/framework/pull/8187.diff","patch_url":"https://github.com/laravel/framework/pull/8187.patch"},"body":"We've been having some issues on some local Windows environments with the new dotenv library. \r\n\r\nWhen you make rapid, successive AJAX requests to a Laravel app, some of the later requests in this chain seem to carry over `putenv()` values from a previous request, but only until the previous request is finished. This sounds strange, I know, but maybe a diagram can help:\r\n\r\n```\r\nRequest 1: {starts --- env loaded --- app uses env ---- finishes}\r\nRequest 2:                         {starts --- env loaded ------ app uses env ---------finishes}\r\n```\r\n\r\nWhen `finishes` happens, PHP clears the values that were set using `putenv()`, but this appears to be affecting values across multiple requests from the same session.\r\n\r\nDebugging `Dotenv` shows us that in the second request, it gets [here](https://github.com/vlucas/phpdotenv/blob/master/src/Dotenv.php#L71) and the environment variable is found...but only when you ask for it from `getenv()`. It's not available in `$_ENV` or `$_SERVER`. Then as the first request dies, it seems to clear out the values previously stored via `putenv()`. I'm not an expert on the PHP innards in Windows, but I suspect this is a bug related to sharing environment data between requests from the same session.\r\n\r\nSo the reason I'm creating this issue here is because Laravel's `env()` helper uses `getenv()`. Unfortunately in our environment, by the time the second request gets there, it's already been unset from the first request. We can tell `Dotenv` to be mutable, thus ensuring the values get stored in all three environment variable types, but that doesn't help us if Laravel still uses `getenv()`. We could create our own `env()` helper, but then we won't be able to keep up to date with any changes to Laravel's.\r\n\r\nThis PR represents what I think is a change that won't affect Laravel in any other environments, but will solve this problem in our Windows environment. Any alternate solution is welcome if this one isn't palatable for some reason."},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/86790971","html_url":"https://github.com/laravel/framework/pull/8187#issuecomment-86790971","issue_url":"https://api.github.com/repos/laravel/framework/issues/8187","id":86790971,"user":{"login":"frankiecmk","id":8033385,"avatar_url":"https://avatars.githubusercontent.com/u/8033385?v=3","gravatar_id":"","url":"https://api.github.com/users/frankiecmk","html_url":"https://github.com/frankiecmk","followers_url":"https://api.github.com/users/frankiecmk/followers","following_url":"https://api.github.com/users/frankiecmk/following{/other_user}","gists_url":"https://api.github.com/users/frankiecmk/gists{/gist_id}","starred_url":"https://api.github.com/users/frankiecmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankiecmk/subscriptions","organizations_url":"https://api.github.com/users/frankiecmk/orgs","repos_url":"https://api.github.com/users/frankiecmk/repos","events_url":"https://api.github.com/users/frankiecmk/events{/privacy}","received_events_url":"https://api.github.com/users/frankiecmk/received_events","type":"User","site_admin":false},"created_at":"2015-03-27T02:34:19Z","updated_at":"2015-03-27T02:34:19Z","body":"> We've been having some issues on some local Windows environments with the new dotenv library.\r\nI'm facing this issue on AWS as well.\r\nPHP 5.5.22 (cli)\r\nServer version: Apache/2.4.10 (Amazon)"}}