Skip to content

Instantly share code, notes, and snippets.

@antonydevanchi
Last active March 14, 2017 01:21
Show Gist options
  • Save antonydevanchi/45ce8ea43832d85f3121f1102ca13e30 to your computer and use it in GitHub Desktop.
Save antonydevanchi/45ce8ea43832d85f3121f1102ca13e30 to your computer and use it in GitHub Desktop.
Laravel Custom Environment and Configuration Load
/*
|--------------------------------------------------------------------------
| Custom Environment and Configuration Load
|--------------------------------------------------------------------------
|
| First of all, we need read what exactly environment we will service.
| If near us we have .env file, than we can read it from it.
|
| After that we expose environment name by variable and
| ask one of $app's methods load configuration params for us.
|
*/
$env = $app->detectEnvironment(function(){
return file_get_contents(__DIR__ . '/../../.env');
});
putenv('APP_ENV=' . $env);
$app->loadEnvironmentFrom('.env.' . getenv('APP_ENV'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment