Skip to content

Commit f4df80b

Browse files
committed
Parse .env
1 parent 0deacc3 commit f4df80b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Console/MetaCommand.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
namespace Barryvdh\LaravelIdeHelper\Console;
1313

1414
use Barryvdh\LaravelIdeHelper\Factories;
15+
use Dotenv\Parser\Entry;
16+
use Dotenv\Parser\Parser;
1517
use Illuminate\Console\Command;
1618
use Illuminate\Contracts\Config\Repository;
1719
use Illuminate\Contracts\View\Factory;
1820
use Illuminate\Filesystem\Filesystem;
1921
use Illuminate\Support\Collection;
22+
use Illuminate\Support\Env;
2023
use RuntimeException;
2124
use Symfony\Component\Console\Input\InputOption;
2225
use Symfony\Component\Console\Output\OutputInterface;
@@ -208,7 +211,7 @@ protected function getExpectedArgumentSets()
208211
return (string) $value;
209212
})->toArray(),
210213
'translations' => $this->loadTemplate('translations')->filter()->keys()->toArray(),
211-
'env' => array_keys($_ENV),
214+
'env' => $this->getEnv(),
212215
];
213216
}
214217

@@ -334,6 +337,16 @@ protected function getOptions()
334337
];
335338
}
336339

340+
protected function getEnv()
341+
{
342+
$parser = new Parser();
343+
$entries = $parser->parse(file_get_contents(base_path('.env')));
344+
345+
return collect($entries)->map(function (Entry $entry) {
346+
return $entry->getName();
347+
});
348+
}
349+
337350
/**
338351
* Remove our custom autoloader that we pushed onto the autoload stack
339352
*

0 commit comments

Comments
 (0)