Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Fix artisan env error #15629

Merged
merged 1 commit into from
Sep 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Dotenv\Dotenv;
use Dotenv\Exception\InvalidPathException;
use Symfony\Component\Console\Input\ArgvInput;
use Illuminate\Contracts\Foundation\Application;

class DetectEnvironment
Expand Down Expand Up @@ -35,12 +36,36 @@ public function bootstrap(Application $app)
*/
protected function checkForSpecificEnvironmentFile($app)
{
if (php_sapi_name() == 'cli') {
$input = new ArgvInput;

if ($input->hasParameterOption('--env')) {
$file = $app->environmentFile().'.'.$input->getParameterOption('--env');

$this->loadEnvironmentFile($app, $file);
}
}

if (! env('APP_ENV')) {
return;
}

$file = $app->environmentFile().'.'.env('APP_ENV');
if (empty($file)) {
$file = $app->environmentFile().'.'.env('APP_ENV');

$this->loadEnvironmentFile($app, $file);
}
}

/**
* Load a custom environment file.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param string $file
* @return void
*/
protected function loadEnvironmentFile($app, $file)
{
if (file_exists($app->environmentPath().'/'.$file)) {
$app->loadEnvironmentFrom($file);
}
Expand Down