35 lines
1.1 KiB
PHP
Executable File
35 lines
1.1 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;
|
|
|
|
class OpcacheClearCommand extends Command
|
|
{
|
|
protected static $defaultName = 'opcache:clear';
|
|
protected static $defaultDescription = 'Limpa o cache do OPcache (PHP)';
|
|
|
|
protected function configure(): void
|
|
{
|
|
$this->setHelp('Este comando executa a função opcache_reset() para invalidar todo o cache de bytecode.');
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
if (!function_exists('opcache_reset')) {
|
|
$output->writeln('<error>OPcache não está habilitado ou a função opcache_reset() não está disponível.</error>');
|
|
return Command::FAILURE;
|
|
}
|
|
|
|
if (opcache_reset()) {
|
|
$output->writeln('<info>OPcache limpo com sucesso!</info>');
|
|
return Command::SUCCESS;
|
|
}
|
|
|
|
$output->writeln('<error>Falha ao limpar o OPcache.</error>');
|
|
return Command::FAILURE;
|
|
}
|
|
}
|