getRoutes(); $output = []; foreach ($routes as $route) { $output[] = $route->toArray(); } if ($json) { echo json_encode($output, JSON_PRETTY_PRINT) . PHP_EOL; } else { printf("%-10s | %-30s | %-20s | %-30s\n", "Method", "Path", "Name", "Handler"); echo str_repeat("-", 100) . PHP_EOL; foreach ($output as $r) { printf("%-10s | %-30s | %-20s | %-30s\n", $r['method'], $r['path'], $r['name'] ?? '', is_string($r['handler']) ? $r['handler'] : 'Closure' ); } } } }