PSR-7 got released May 4, 2015. There is a discussion about middlewares based on PSR-7 messages, and it is awfully overdue. The most common middlewares in use since June 2015 are callables with this interface:
They just work. I’ve been using them since June 2015. You can stack a number of middlewares with tools like relay/relay or mindplay/middleman. I prefer the latter because it plays well with container-interop
containers to resolve middlewares when you need them.
Granted, you can use them wrong by fiddling with the Response before passing it on to the next middleware. Just don’t do that. But I’d rather educate newbies than to remodel the whole thing and to make it overly complex. I’ve been giving this PSR-7 talk for 12! months now. Please just spread the word and stop discussing something that has been in use for over a year now.
Thanks.
PSR-7 middlewares discussion links:
- Anthony Ferrara’s post
- Woody Gilk’s post
- Phil Sturgeon’s post
- Andrew Carter educating that the StreamInterface isn’t immutable
- PHP-FIG discussion on google groups
- PHP league discussion on google groups
Some links might be missing here. Feel free to send a PR.