The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

calling a custom middleware function

joe's Avatar

joe

10 May, 2012 01:13 AM

Hello,

Just started playing with Slim a few days ago and I'm trying to figure out if something is possible.

I created a new Middleware class and added it to Slim. I want to access a variable that I have set inside that new class, but it's not clear how I would go about getting to a function I have defined in a piece of middleware

Inside my route I tried a couple of different things, but nothing seemed to work. Check out the gist to see what I'm talking about.

https://gist.github.com/2650234

Is there any way to do what I'm trying to do?

Thanks,
Joe

  1. Support Staff 1 Posted by Josh Lockhart on 10 May, 2012 01:30 AM

    Josh Lockhart's Avatar

    Middleware exists so you can tweak the request and response before and/or after the Slim application is run. There are many ways this can be useful... custom session handlers, authentication, request logging, etc.

    You may be more interested in hooks; these existing within the application. Middleware acts outside the application (around it... if that makes sense). More details are in the online documentation.

    Josh

  2. 2 Posted by joe on 10 May, 2012 01:32 AM

    joe's Avatar

    Ahh, ok that makes sense. Thanks for the quick reply.

  3. Andrew Smith closed this discussion on 08 Aug, 2012 09:59 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? 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