manager-bundle/src/ContaoManager/ApiCommand/RemoveDotEnvCommand.php
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        $fs = new Filesystem();
        $path = $this->projectDir.'/.env';

        if (!$fs->exists($path)) {
            return;
        }

        $content = '';
        $lines = file($path, FILE_IGNORE_NEW_LINES);

        if (false === $lines) {
            throw new \RuntimeException(sprintf('Could not read "%s" file.', $path));
        }

        $key = $input->getArgument('key');

        foreach ($lines as $line) {
            if (0 === strpos($line, $key.'=')) {
                continue;
            }

            $content .= $line."\n";
        }

        if (empty($content)) {
            $fs->remove($path);
        } else {
            $fs->dumpFile($path, $content);
        }
    }
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        $fs = new Filesystem();
        $path = $this->projectDir.'/.env';

        if (!$fs->exists($path)) {
            return;
        }

        $content = '';
        $lines = file($path, FILE_IGNORE_NEW_LINES);

        if (false === $lines) {
            throw new \RuntimeException(sprintf('Could not read "%s" file.', $path));
        }

        $key = $input->getArgument('key');

        foreach ($lines as $line) {
            if (0 === strpos($line, $key.'=')) {
                continue;
            }

            $content .= $line."\n";
        }

        if (empty($content)) {
            $fs->remove($path);
        } else {
            $fs->dumpFile($path, $content);
        }
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) : void { $ fs = new Filesystem ( ) ; $ path = $ this -> projectDir . '/.env' ; if ( ! $ fs -> exists ( $ path ) ) { return ; } $ content = '' ; $ lines = file ( $ path , FILE_IGNORE_NEW_LINES ) ; if ( false === $ lines ) { throw new \ RuntimeException ( sprintf ( 'Could not read "%s" file.' , $ path ) ) ; } $ key = $ input -> getArgument ( 'key' ) ; foreach ( $ lines as $ line ) { if ( 0 === strpos ( $ line , $ key . '=' ) ) { continue ; } $ content .= $ line . "\n" ; } if ( empty ( $ content ) ) { $ fs -> remove ( $ path ) ; } else { $ fs -> dumpFile ( $ path , $ content ) ; } }
{@inheritdoc}
{