writeln("Arquivo .env não encontrado."); return Command::FAILURE; } $content = file_get_contents($envFile); if (strpos($content, 'APP_KEY=') !== false) { $content = preg_replace('/APP_KEY=.*/', 'APP_KEY=' . $key, $content); } else { $content .= "\nAPP_KEY=" . $key; } if (file_put_contents($envFile, $content)) { $output->writeln("APP_KEY gerada com sucesso!"); $output->writeln("Chave: {$key}"); return Command::SUCCESS; } else { $output->writeln("Falha ao escrever no arquivo .env."); return Command::FAILURE; } } }