Skip to content

Instantly share code, notes, and snippets.

@zabaala
Last active April 6, 2022 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zabaala/705bcae469f7d4dbb3c08edb2d2b307e to your computer and use it in GitHub Desktop.
Save zabaala/705bcae469f7d4dbb3c08edb2d2b307e to your computer and use it in GitHub Desktop.
List Slim 4 registered routes
<?php
// Slim 4.
$routes = $app->getRouteCollector()->getRoutes();
$output = [];
/** Slim\Routing\Route $route */
foreach ($routes as $route) {
$output[] = [
'methods' => $route->getMethods(),
'pattern' => $route->getPattern(),
'name' => $route->getName(),
'identifier' => $route->getIdentifier(),
'action' => is_object($route->getCallable()) ? get_class((object) $route->getCallable()) : '[closure]',
];
}
var_dump($output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment