Skip to content

Commit

Permalink
Fix artisan env error
Browse files Browse the repository at this point in the history
  • Loading branch information
srmklive committed Sep 27, 2016
1 parent d03eddb commit 6b76faa
Showing 1 changed file with 26 additions and 1 deletion.
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

1 comment on commit 6b76faa

@marjetika
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this file available with 5.5 distribution?

Please sign in to comment.