The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

How to get route name in middleware class

timoto.tito's Avatar


25 Nov, 2015 06:34 AM

Hi Friends,

I am writing small code using Slim V3. I implemented new class for middleware. Now, I want to write two logics based on route name. if user need to write some code if comments need to write some code. So, How to find route name from Middleware.


  1. 1 Posted by Rob Allen on 25 Nov, 2015 08:01 AM

    Rob Allen's Avatar

    Set the setting 'determineRouteBeforeAppMiddleware':

    $app = new Slim\App(['settings'=>['determineRouteBeforeAppMiddleware'=>true]]);

    Then you can get at the route in the attributes of the $request in your middleware.

  2. 2 Posted by timoto.tito on 25 Nov, 2015 05:09 PM

    timoto.tito's Avatar

    Thank you Rob. It is working fine :)

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac