Skip to content

Commit

Permalink
Rename DetectEnvironment to LoadEnvironmentVariables.
Browse files Browse the repository at this point in the history
This bootstrapped didn’t actually “detect” the environment. It just
loads the environment variables.
  • Loading branch information
taylorotwell committed Dec 28, 2016
1 parent 57fe0ab commit c36874d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
24 changes: 8 additions & 16 deletions src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down Expand Up @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Symfony\Component\Console\Input\ArgvInput;
use Illuminate\Contracts\Foundation\Application;

class DetectEnvironment
class LoadEnvironmentVariables
{
/**
* Bootstrap the given application.
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/Foundation/FoundationApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c36874d

Please sign in to comment.