Files
2026-09-01 10:46:29 -03:00

39 lines
1.4 KiB
PHP
Executable File

<?php
namespace App\Console\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\ArrayInput;
class AppOptimizeCommand extends Command
{
protected static $defaultName = 'app:optimize';
protected static $defaultDescription = 'Otimiza a aplicação limpando caches e bancos de dados (comandos combinados)';
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('<info>Iniciando otimização completa do sistema...</info>');
// 1. Clear Cache
$output->writeln("\n<comment>Limpando caches...</comment>");
$cacheCommand = $this->getApplication()->find('cache:clear');
$cacheCommand->run(new ArrayInput([]), $output);
// 2. Clear Logs
$output->writeln("\n<comment>Limpando logs...</comment>");
$logsCommand = $this->getApplication()->find('logs:clear');
$logsCommand->run(new ArrayInput([]), $output);
// 3. Optimize DB
$output->writeln("\n<comment>Otimizando banco de dados...</comment>");
$dbCommand = $this->getApplication()->find('db:optimize');
$dbCommand->run(new ArrayInput([]), $output);
$output->writeln("\n<info>Aplicação otimizada com sucesso!</info>");
return Command::SUCCESS;
}
}