About addRoutingMiddleware (Routing middleware) [SLIM 4]

I still don’t really understand about $app->addRoutingMiddleware();
are there examples of functions/effect and how to use them?

I really hope you help me.
Thank u.

Hi @mochalvi

  1. The RoutingMiddleware allows you to add some middleware before routing and some after.
  2. If you want to implement another routing library you could by create your own implementations of the routing interfaces

Here you can find more infos about the RoutingMiddleware:

if the syntax $app->addRoutingMiddleware(); is not used, then the middleware will be executed after routing?

If you don’t invoke $app->addRoutingMiddleware(); then

  1. Slim does the routing after your middleware stack has been processed.
  2. The RouteParser is not available within the request object. This could have some strange effects.

Ok, very helpful :smiley:
Thank u @odan :blush: