I want to get the name of the current I route in a middleware class. Previously (in Slim 2.*) you could fetch the current route like so:
$route = $this->ap
Here's how you get current route in your middleware in Slim framework 3:
$routeInfo = $request->getAttribute('routeInfo');
Note that you should use this inside __invoke()
function in your middleware. Here's the sample usage:
public function __invoke($request, $response, $next)
{
....
$routeInfo = $request->getAttribute('routeInfo');
....
}
$routeInfo shall then contain an object like:
{
"0": 1,
"1": "route6",
"2": {
"name": "loremipsum"
},
"request": [
"POST",
"http://example.org/loremipsum"
]
}