-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Dotenv] Add --dotenv-path option to DotenvDumpCommand #52553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ protected function configure(): void | |
new InputArgument('env', null === $this->defaultEnv ? InputArgument::REQUIRED : InputArgument::OPTIONAL, 'The application environment to dump .env files for - e.g. "prod".'), | ||
]) | ||
->addOption('empty', null, InputOption::VALUE_NONE, 'Ignore the content of .env files') | ||
->addOption('dotenv-path', null, InputOption::VALUE_OPTIONAL, 'Path to .env file') | ||
->setHelp(<<<'EOT' | ||
The <info>%command.name%</info> command compiles .env files into a PHP-optimized file called .env.local.php. | ||
|
||
|
@@ -66,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
|
||
$composerFile = $projectDir.'/composer.json'; | ||
$config += (is_file($composerFile) ? json_decode(file_get_contents($composerFile), true) : [])['extra']['runtime'] ?? []; | ||
$dotenvPath = $projectDir.'/'.($config['dotenv_path'] ?? '.env'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have second thoughts on this. Maybe we should set the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it doesn't matter. |
||
$dotenvPath = $projectDir.'/'.($input->getOption('dotenv-path') ?? $config['dotenv_path'] ?? '.env'); | ||
$env = $input->getArgument('env') ?? $this->defaultEnv; | ||
$envKey = $config['env_var_name'] ?? 'APP_ENV'; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line looks like you can set
dotenv_path
in your composer.json file:In that case this PR would not be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed for cases when the .env file name contains an env name, like a
local.env
,dev.env
,prod.env
.