6 declare(strict_types = 1);
10 use Symfony\Component\Console\Command\Command;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Exception\InvalidOptionException;
13 use Symfony\Component\Console\Input\InputInterface;
14 use Symfony\Component\Console\Output\OutputInterface;
24 private $envProcessor;
33 $this->setName(
'setup:env')
34 ->setDescription(
"Generate .env file.");
35 $this->envProcessor =
new EnvProcessor(TESTS_BP . DIRECTORY_SEPARATOR .
'.env');
36 $env = $this->envProcessor->getEnv();
37 foreach ($env as $key =>
$value) {
38 $this->addOption($key,
null, InputOption::VALUE_REQUIRED,
'',
$value);
52 $config = $this->envProcessor->getEnv();
55 if ($input->getOption($key) ===
'') {
56 throw new InvalidOptionException(sprintf(
"Parameter $key cannot be empty.", $key));
58 $userEnv[$key] = $input->getOption($key);
60 $this->envProcessor->putEnvFile($userEnv);
61 $output->writeln(
".env configuration successfully applied.");
execute(InputInterface $input, OutputInterface $output)