First Commit

This commit is contained in:
marco
2026-09-01 10:46:29 -03:00
commit bf96b77e9c
10000 changed files with 3508600 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace App\Console\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class AppRenameCommand extends Command
{
protected static $defaultName = 'app:rename';
protected static $defaultDescription = 'Altera o nome da aplicação no arquivo .env';
protected function configure(): void
{
$this
->addArgument('name', InputArgument::REQUIRED, 'O novo nome da aplicação');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$newName = $input->getArgument('name');
$envFile = dirname(__DIR__, 3) . '/.env';
if (!file_exists($envFile)) {
$output->writeln('<error>Arquivo .env não encontrado.</error>');
return Command::FAILURE;
}
$content = file_get_contents($envFile);
$pattern = "/APP_NAME=(.*)/";
$replacement = "APP_NAME=\"{$newName}\"";
if (preg_match($pattern, $content)) {
$newContent = preg_replace($pattern, $replacement, $content);
} else {
$newContent = $content . "\nAPP_NAME=\"{$newName}\"";
}
if (file_put_contents($envFile, $newContent)) {
$output->writeln("<info>Aplicação renomeada para '{$newName}' com sucesso!</info>");
return Command::SUCCESS;
}
$output->writeln('<error>Falha ao renomear a aplicação.</error>');
return Command::FAILURE;
}
}