Last active
March 14, 2017 01:21
-
-
Save antonydevanchi/45ce8ea43832d85f3121f1102ca13e30 to your computer and use it in GitHub Desktop.
Laravel Custom Environment and Configuration Load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
|-------------------------------------------------------------------------- | |
| 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