Search code examples
slim-4

How to get registered routes in Slim Framework 4


In Slim Framework 3 we can get all registered routes using this code

$routes = $this->container->get("router")->getRoutes();

Unfortunately this doesn't seem to work in slim 4. Is there any other way to get registered routes in slim 4 ?

thanks


Solution

  • After browsing the codes, found out that you can get all routes from the RouteCollectorProxy. Here's an example :

    $routes = $app->getRouteCollector()->getRoutes();