From c36874dda29d8eb9f9364c4bd308c7ee10060c25 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 28 Dec 2016 10:01:42 -0600 Subject: [PATCH] Rename DetectEnvironment to LoadEnvironmentVariables. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This bootstrapped didn’t actually “detect” the environment. It just loads the environment variables. --- src/Illuminate/Foundation/Application.php | 2 +- .../Bootstrap/LoadConfiguration.php | 24 +++++++------------ ...nment.php => LoadEnvironmentVariables.php} | 2 +- src/Illuminate/Foundation/Console/Kernel.php | 2 +- src/Illuminate/Foundation/Http/Kernel.php | 2 +- .../Foundation/FoundationApplicationTest.php | 4 ++-- 6 files changed, 14 insertions(+), 22 deletions(-) rename src/Illuminate/Foundation/Bootstrap/{DetectEnvironment.php => LoadEnvironmentVariables.php} (98%) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index c94ece2a13cb..bf097ba3d7b4 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -218,7 +218,7 @@ public function bootstrapWith(array $bootstrappers) public function afterLoadingEnvironment(Closure $callback) { return $this->afterBootstrapping( - 'Illuminate\Foundation\Bootstrap\DetectEnvironment', $callback + 'Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables', $callback ); } diff --git a/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php b/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php index fb9aaf3dbec2..bdaba54fe398 100644 --- a/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php +++ b/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php @@ -28,20 +28,25 @@ public function bootstrap(Application $app) $loadedFromCache = true; } - $app->instance('config', $config = new Repository($items)); - // Next we will spin through all of the configuration files in the configuration // directory and load each one into the repository. This will make all of the // options available to the developer for use in various parts of this app. + $app->instance('config', $config = new Repository($items)); + if (! isset($loadedFromCache)) { $this->loadConfigurationFiles($app, $config); } + // Finally, we will set the application's environment based on the configuration + // values that were loaded. We will pass a callback which will be used to get + // the environment in a web context where an "--env" switch is not present. $app->detectEnvironment(function () use ($config) { return $config->get('app.env', 'production'); }); - $this->setPhpConfiguration($config); + date_default_timezone_set($config->get('app.timezone', 'UTC')); + + mb_internal_encoding('UTF-8'); } /** @@ -74,17 +79,4 @@ protected function getConfigurationFiles(Application $app) return $files; } - - /** - * Set a few PHP configuration options. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @return void - */ - protected function setPhpConfiguration(RepositoryContract $config) - { - date_default_timezone_set($config->get('app.timezone', 'UTC')); - - mb_internal_encoding('UTF-8'); - } } diff --git a/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php b/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php similarity index 98% rename from src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php rename to src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php index ba260ba3b185..b6707129d360 100644 --- a/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php +++ b/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\ArgvInput; use Illuminate\Contracts\Foundation\Application; -class DetectEnvironment +class LoadEnvironmentVariables { /** * Bootstrap the given application. diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index 9a1aa59c7388..7f309e66e9a4 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -56,7 +56,7 @@ class Kernel implements KernelContract * @var array */ protected $bootstrappers = [ - 'Illuminate\Foundation\Bootstrap\DetectEnvironment', + 'Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', diff --git a/src/Illuminate/Foundation/Http/Kernel.php b/src/Illuminate/Foundation/Http/Kernel.php index a9edcf7edc63..9a9c4265b83d 100644 --- a/src/Illuminate/Foundation/Http/Kernel.php +++ b/src/Illuminate/Foundation/Http/Kernel.php @@ -34,7 +34,7 @@ class Kernel implements KernelContract * @var array */ protected $bootstrappers = [ - \Illuminate\Foundation\Bootstrap\DetectEnvironment::class, + \Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class, \Illuminate\Foundation\Bootstrap\LoadConfiguration::class, \Illuminate\Foundation\Bootstrap\HandleExceptions::class, \Illuminate\Foundation\Bootstrap\RegisterFacades::class, diff --git a/tests/Foundation/FoundationApplicationTest.php b/tests/Foundation/FoundationApplicationTest.php index 3c89d0f510b6..ad806e2841d2 100755 --- a/tests/Foundation/FoundationApplicationTest.php +++ b/tests/Foundation/FoundationApplicationTest.php @@ -145,8 +145,8 @@ public function testMethodAfterLoadingEnvironmentAddsClosure() $closure = function () { }; $app->afterLoadingEnvironment($closure); - $this->assertArrayHasKey(0, $app['events']->getListeners('bootstrapped: Illuminate\Foundation\Bootstrap\DetectEnvironment')); - $this->assertSame($closure, $app['events']->getListeners('bootstrapped: Illuminate\Foundation\Bootstrap\DetectEnvironment')[0]); + $this->assertArrayHasKey(0, $app['events']->getListeners('bootstrapped: Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables')); + $this->assertSame($closure, $app['events']->getListeners('bootstrapped: Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables')[0]); } public function testBeforeBootstrappingAddsClosure()