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

43 lines
1.3 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\Helper\Table;
use Kernel\Application;
class DebugRouterCommand extends Command
{
protected static $defaultName = 'debug:router';
protected static $defaultDescription = 'Lista detalhes das rotas registradas na aplicação';
protected function execute(InputInterface $input, OutputInterface $output): int
{
$app = Application::getInstance();
if (!$app) {
$output->writeln('<error>Não foi possível obter a instância da aplicação.</error>');
return Command::FAILURE;
}
$routes = $app->getRoutes();
$output->writeln('<info>Rotas Registradas:</info>');
$table = new Table($output);
$table->setHeaders(['Método', 'Caminho', 'Handler']);
foreach ($routes as $route) {
[$method, $path, $handler] = $route;
$handlerStr = is_array($handler) ? implode('@', $handler) : 'Closure';
$table->addRow([$method, $path, $handlerStr]);
}
$table->render();
return Command::SUCCESS;
}
}