Skip to content

Commit c36874d

Browse files
committed
Rename DetectEnvironment to LoadEnvironmentVariables.
This bootstrapped didn’t actually “detect” the environment. It just loads the environment variables.
1 parent 57fe0ab commit c36874d

6 files changed

Lines changed: 14 additions & 22 deletions

File tree

src/Illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function bootstrapWith(array $bootstrappers)
218218
public function afterLoadingEnvironment(Closure $callback)
219219
{
220220
return $this->afterBootstrapping(
221-
'Illuminate\Foundation\Bootstrap\DetectEnvironment', $callback
221+
'Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables', $callback
222222
);
223223
}
224224

src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,25 @@ public function bootstrap(Application $app)
2828
$loadedFromCache = true;
2929
}
3030

31-
$app->instance('config', $config = new Repository($items));
32-
3331
// Next we will spin through all of the configuration files in the configuration
3432
// directory and load each one into the repository. This will make all of the
3533
// options available to the developer for use in various parts of this app.
34+
$app->instance('config', $config = new Repository($items));
35+
3636
if (! isset($loadedFromCache)) {
3737
$this->loadConfigurationFiles($app, $config);
3838
}
3939

40+
// Finally, we will set the application's environment based on the configuration
41+
// values that were loaded. We will pass a callback which will be used to get
42+
// the environment in a web context where an "--env" switch is not present.
4043
$app->detectEnvironment(function () use ($config) {
4144
return $config->get('app.env', 'production');
4245
});
4346

44-
$this->setPhpConfiguration($config);
47+
date_default_timezone_set($config->get('app.timezone', 'UTC'));
48+
49+
mb_internal_encoding('UTF-8');
4550
}
4651

4752
/**
@@ -74,17 +79,4 @@ protected function getConfigurationFiles(Application $app)
7479

7580
return $files;
7681
}
77-
78-
/**
79-
* Set a few PHP configuration options.
80-
*
81-
* @param \Illuminate\Contracts\Config\Repository $config
82-
* @return void
83-
*/
84-
protected function setPhpConfiguration(RepositoryContract $config)
85-
{
86-
date_default_timezone_set($config->get('app.timezone', 'UTC'));
87-
88-
mb_internal_encoding('UTF-8');
89-
}
9082
}

src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php renamed to src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Symfony\Component\Console\Input\ArgvInput;
88
use Illuminate\Contracts\Foundation\Application;
99

10-
class DetectEnvironment
10+
class LoadEnvironmentVariables
1111
{
1212
/**
1313
* Bootstrap the given application.

src/Illuminate/Foundation/Console/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Kernel implements KernelContract
5656
* @var array
5757
*/
5858
protected $bootstrappers = [
59-
'Illuminate\Foundation\Bootstrap\DetectEnvironment',
59+
'Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables',
6060
'Illuminate\Foundation\Bootstrap\LoadConfiguration',
6161
'Illuminate\Foundation\Bootstrap\HandleExceptions',
6262
'Illuminate\Foundation\Bootstrap\RegisterFacades',

src/Illuminate/Foundation/Http/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Kernel implements KernelContract
3434
* @var array
3535
*/
3636
protected $bootstrappers = [
37-
\Illuminate\Foundation\Bootstrap\DetectEnvironment::class,
37+
\Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class,
3838
\Illuminate\Foundation\Bootstrap\LoadConfiguration::class,
3939
\Illuminate\Foundation\Bootstrap\HandleExceptions::class,
4040
\Illuminate\Foundation\Bootstrap\RegisterFacades::class,

tests/Foundation/FoundationApplicationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ public function testMethodAfterLoadingEnvironmentAddsClosure()
145145
$closure = function () {
146146
};
147147
$app->afterLoadingEnvironment($closure);
148-
$this->assertArrayHasKey(0, $app['events']->getListeners('bootstrapped: Illuminate\Foundation\Bootstrap\DetectEnvironment'));
149-
$this->assertSame($closure, $app['events']->getListeners('bootstrapped: Illuminate\Foundation\Bootstrap\DetectEnvironment')[0]);
148+
$this->assertArrayHasKey(0, $app['events']->getListeners('bootstrapped: Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables'));
149+
$this->assertSame($closure, $app['events']->getListeners('bootstrapped: Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables')[0]);
150150
}
151151

152152
public function testBeforeBootstrappingAddsClosure()

0 commit comments

Comments
 (0)