Skip to content

Commit 5a34c60

Browse files
committed
Simplify environment loading.
1 parent 6980d95 commit 5a34c60

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.env.*
21
/.idea
32
/vendor
3+
.env
44
.DS_Store
55
Thumbs.db
66
composer.lock

bootstrap/environment.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
<?php
22

3+
/*
4+
|--------------------------------------------------------------------------
5+
| Load Environment Variables
6+
|--------------------------------------------------------------------------
7+
|
8+
| Next we will load the environment variables for the application which
9+
| are stored in the ".env" file. These variables will be loaded into
10+
| the $_ENV and "putenv" facilities of PHP so they stay available.
11+
|
12+
*/
13+
14+
try
15+
{
16+
Dotenv::load(__DIR__.'/../');
17+
18+
Dotenv::required('APP_ENV');
19+
}
20+
catch (RuntimeException $e)
21+
{
22+
die('Application environment not configured.'.PHP_EOL);
23+
}
24+
325
/*
426
|--------------------------------------------------------------------------
527
| Detect The Application Environment
@@ -11,8 +33,7 @@
1133
|
1234
*/
1335

14-
$env = $app->detectEnvironment([
15-
16-
'local' => ['homestead'],
17-
18-
]);
36+
$env = $app->detectEnvironment(function()
37+
{
38+
return getenv('APP_ENV');
39+
});

0 commit comments

Comments
 (0)