diff --git a/Command/DebugCommand.php b/Command/DebugCommand.php index d0c2723..0315b77 100644 --- a/Command/DebugCommand.php +++ b/Command/DebugCommand.php @@ -81,7 +81,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 1; } - $filePath = $_SERVER['SYMFONY_DOTENV_PATH'] ?? $this->projectDirectory.\DIRECTORY_SEPARATOR.'.env'; + if (!$filePath = $_SERVER['SYMFONY_DOTENV_PATH'] ?? null) { + $dotenvPath = $this->projectDirectory; + + if (is_file($composerFile = $this->projectDirectory.'/composer.json')) { + $runtimeConfig = (json_decode(file_get_contents($composerFile), true))['extra']['runtime'] ?? []; + + if (isset($runtimeConfig['dotenv_path'])) { + $dotenvPath = $this->projectDirectory.'/'.$runtimeConfig['dotenv_path']; + } + } + + $filePath = $dotenvPath.'/.env'; + } $envFiles = $this->getEnvFiles($filePath); $availableFiles = array_filter($envFiles, 'is_file');