Closed mbretter closed 8 years ago
Take a look here https://github.com/slimphp/Slim/issues/1594#issuecomment-157010524
$request->getAttribute('route')
thx!
If you are accessing this attribute within an app middleware it's important to set 'determineRouteBeforeAppMiddleware' => true, otherwise $request->getAttribute('route') returns null
@silentworks Thank you, man. Finally I got it.
Set in the app config - 'determineRouteBeforeAppMiddleware' => true
$request->getAttribute('route')->getName()
I am having some trouble with this. I am getting null when i do $request->getAttribute('route')->getName()
. And I have also the determineRouteBeforeAppMiddleware' => true
in the settings.php.
Anyone has any suggestion?
@Motard The Url hasn't matched or you haven't called ->setName()
after you defined your route.
Thx @akrabat. The problem was the missing ->setName()
after declaring the route.
Hi,
during the migration from Slim2 => 3, I have not found a way in slim3 to get the current Route, in slim2 it was $app->router()->getCurrentRoute()
thx, cheers