Last active
April 6, 2022 18:38
-
-
Save zabaala/705bcae469f7d4dbb3c08edb2d2b307e to your computer and use it in GitHub Desktop.
List Slim 4 registered routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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