Skip to content

Commit

Permalink
Local neon task: Use safe getenv() function for get all global enviro…
Browse files Browse the repository at this point in the history
…nment variables.
  • Loading branch information
janbarasek authored Jul 14, 2021
1 parent ae31bed commit 6355245
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/InteractiveComposer/Task/ConfigLocalNeonTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class ConfigLocalNeonTask extends BaseTask
public function run(): bool
{
$path = \dirname(__DIR__, 6) . '/app/config/local.neon';
$environment = getenv();
try {
$doctrineExist = interface_exists('Doctrine\ORM\EntityManagerInterface');
} catch (\Throwable) {
Expand All @@ -59,9 +60,9 @@ public function run(): bool
}
echo 'Configuration is empty.' . "\n";
}
if ($_ENV !== []) {
if (is_array($environment) && $environment !== []) {
echo 'Auto detected environment settings: ' . "\n";
foreach ($_ENV as $key => $value) {
foreach ($environment as $key => $value) {
echo ' ' . ConsoleHelpers::terminalRenderLabel((string) $key) . ': ';
if (is_scalar($value)) {
echo $value;
Expand All @@ -72,7 +73,7 @@ public function run(): bool
}
echo "\n\n";
}
$connectionString = $_ENV['DB_URI'] ?? null;
$connectionString = $environment['DB_URI'] ?? null;
if ($connectionString !== null) {
echo 'Use connection string.';
file_put_contents($path, '');
Expand Down

0 comments on commit 6355245

Please sign in to comment.