[Slim 4] Get router in controller

#1

Before (in Slim 3), to get a route from a Controller you could do:
$container->router->pathFor('route')

But how do we do it now?

#2

You need to obtain the RouteParser from the RouteCollector

$app = AppFactory::create();

$routeParser = $app->getRouteCollector()->getRouteParser();

// pathFor() has been replaced by urlFor()
$routeParser->urlFor(...);
#3

Oh, yes, indeed. Thank you :slight_smile: