-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC][DotEnv] Move Flex dump-env command to DotEnv component #32093
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
Comments
Doesn't this create a circular dependency in case you changed something in your Dotfile? As the symfony command would itself use symfony for dumping the vars, it might run into problems. By being a composer command it is decoupled from Symfony, which is a good thing (in this case). A solution would be to add the command as standalone executable. |
That's what I'm thinking about. Just forgot to write it down! |
The core of the code we're talking about would look like this (copy-pasted from https://github.com/symfony/flex/blob/master/src/Command/DumpEnvCommand.php): function dumpEnv(string $path, string $env)
{
$globalsBackup = [$_SERVER, $_ENV];
unset($_SERVER['APP_ENV']);
$_ENV = ['APP_ENV' => $env];
$_SERVER['SYMFONY_DOTENV_VARS'] = implode(',', array_keys($_SERVER));
putenv('SYMFONY_DOTENV_VARS='.$_SERVER['SYMFONY_DOTENV_VARS']);
try {
$this->loadEnv($path);
unset($_ENV['SYMFONY_DOTENV_VARS']);
$vars = $_ENV;
} finally {
list($_SERVER, $_ENV) = $globalsBackup;
}
$vars = var_export($vars, true);
$vars = <<<EOF
<?php
// This file was generated by dumping the "$env" env
return $vars;
EOF;
file_put_contents($path.'.local.php', $vars, LOCK_EX);
} I wouldn't make this a command in the component. |
@fbourigault up for a PR? Otherwise we might close I think. |
It’s still on my todo list ;) |
this is a good idea. The |
Well, the component might expose its own script |
Thank you for this suggestion. |
This is implemented since Symfony 5.4 🎉 (see #42610) |
I would suggest to move the dump-env command from Flex to the DotEnv component as a standalone executable.
By doing so, anybody using the DotEnv standalone component would be able to use the dumped environment feature.
Also the
symfony:dump-env
could proxy to the component script to keep the current behavior and DX.WDYT?
The text was updated successfully, but these errors were encountered: