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
ok. but don’t work
The Slim middleware is LIFO (last in, first out). Try to add your middleware first.
Source code: https://pastebin.com/FxxM8AiA