Slim 4 get name route

Hi!
Error: Cannot create RouteContext before routing has been completed
How fix it?

You just need to add your routingMiddleware before the middleware or handler where you are trying to create that routeContext.

From the documentation

The routing middleware should be added earlier than the ErrorMiddleware
Otherwise exceptions thrown from it will not be handled by the middleware

Error Handling Middleware

ok. but don’t work
example: https://pastebin.com/FxxM8AiA

The Slim middleware is LIFO (last in, first out). Try to add your middleware first.

1 Like

Thanks!
It’s working.
Source code: https://pastebin.com/FxxM8AiA