Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f4345f

Browse files
committed
read runtime config from composer.json in debug dotenv command
1 parent ec691c8 commit 9f4345f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Symfony/Component/Dotenv/Command/DebugCommand.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5050
return 1;
5151
}
5252

53-
$filePath = $this->projectDirectory.\DIRECTORY_SEPARATOR.'.env';
53+
$dotenvPath = $this->projectDirectory;
54+
55+
if (is_file($composerFile = $this->projectDirectory.'/composer.json')) {
56+
$runtimeConfig = (json_decode(file_get_contents($composerFile), true))['extra']['runtime'] ?? [];
57+
58+
if (isset($runtimeConfig['dotenv_path'])) {
59+
$dotenvPath = $this->projectDirectory.'/'.$runtimeConfig['dotenv_path'];
60+
}
61+
}
62+
63+
$filePath = $dotenvPath.'/.env';
5464
$envFiles = $this->getEnvFiles($filePath);
5565
$availableFiles = array_filter($envFiles, 'is_file');
5666

0 commit comments

Comments
 (0)