# About addRoutingMiddleware (Routing middleware) \[SLIM 4\]

**URL:** <https://discourse.slimframework.com/t/about-addroutingmiddleware-routing-middleware-slim-4/3957>\
**Category:** Questions\
**Created:** [March 23, 2020, 9:37am UTC](https://discourse.slimframework.com/t/about-addroutingmiddleware-routing-middleware-slim-4/3957 "2020-03-23T09:37:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mochalvi](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/mochalvi/32/1108_2.png) [@mochalvi](https://discourse.slimframework.com/u/mochalvi)\
**Post date:** [March 23, 2020, 9:37am UTC](https://discourse.slimframework.com/t/about-addroutingmiddleware-routing-middleware-slim-4/3957/1 "2020-03-23T09:37:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [March 23, 2020, 5:12pm UTC](https://discourse.slimframework.com/t/about-addroutingmiddleware-routing-middleware-slim-4/3957/2 "2020-03-23T17:12:38Z")

</div>

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:

- [http://www.slimframework.com/docs/v4/start/upgrade.html#new-routing-middleware](http://www.slimframework.com/docs/v4/start/upgrade.html#new-routing-middleware)
- [http://www.slimframework.com/docs/v4/middleware/routing.html](http://www.slimframework.com/docs/v4/middleware/routing.html)
- [https://github.com/slimphp/Slim/pull/2288](https://github.com/slimphp/Slim/pull/2288)

---

<div class="post-metadata">

**Author:** ![mochalvi](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/mochalvi/32/1108_2.png) [@mochalvi](https://discourse.slimframework.com/u/mochalvi)\
**Post date:** [March 24, 2020, 5:29am UTC](https://discourse.slimframework.com/t/about-addroutingmiddleware-routing-middleware-slim-4/3957/3 "2020-03-24T05:29:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [March 25, 2020, 8:37am UTC](https://discourse.slimframework.com/t/about-addroutingmiddleware-routing-middleware-slim-4/3957/4 "2020-03-25T08:37:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mochalvi](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/mochalvi/32/1108_2.png) [@mochalvi](https://discourse.slimframework.com/u/mochalvi)\
**Post date:** [March 26, 2020, 3:34am UTC](https://discourse.slimframework.com/t/about-addroutingmiddleware-routing-middleware-slim-4/3957/5 "2020-03-26T03:34:32Z")

</div>

Ok, very helpful 😃  
Thank u @odan 😊
