Просмотр файла app/Commands/RouteClear.php

Размер файла: 921B
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace App\Commands;
  6.  
  7. use Phinx\Console\Command\AbstractCommand;
  8. use Symfony\Component\Console\Input\InputInterface;
  9. use Symfony\Component\Console\Output\OutputInterface;
  10.  
  11. class RouteClear extends AbstractCommand
  12. {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. protected function configure(): void
  17. {
  18. parent::configure();
  19.  
  20. $this->setName('route:clear')
  21. ->setDescription('Flush the routes cache');
  22. }
  23.  
  24. /**
  25. * Route cleared
  26. *
  27. * @param InputInterface $input
  28. * @param OutputInterface $output
  29. *
  30. * @return int
  31. */
  32. protected function execute(InputInterface $input, OutputInterface $output): int
  33. {
  34. if (file_exists(STORAGE . '/caches/routes.php')) {
  35. unlink(STORAGE . '/caches/routes.php');
  36. }
  37.  
  38. $output->writeln('<info>Routes cleared successfully.</info>');
  39.  
  40. return 0;
  41. }
  42. }