Hi @Vino I see at least 2 or 3 issue in this codebase.
-
The container is not fully initialized. Better create the PHP-DI container with the ContainerBuilder.
-
Use RouteContext to retrieving the current route.
- http://www.slimframework.com/docs/v4/cookbook/retrieving-current-route.html
- http://www.slimframework.com/docs/v4/start/upgrade.html#new-dispatcher--routing-results
- A route can be
null
. You should check it before you can use it.
-
A last tip: Use the the
BasePathMiddleware
as decribed here.