10

I'm looking for a way to create a Django-like middleware for an application on Symfony2. Basically, I need to preprocess every request before it comes to Controllers and postprocess every response after Controllers, but before it comes to user.

Any thoughts?

gakhov
  • 1,925
  • 4
  • 27
  • 39

2 Answers2

19

You don't need a middle ware for this in Symfony2. There are things called Kernel Events.

http://symfony.com/doc/current/book/internals.html#events

You may want to have a look at kernel.request and kernel.response

  • 1
    I have implemented this way and it works in SF4! By implementing with Kernel Events gives more control on different levels of a request/response – Sam Jan 25 '18 at 04:43
7

StackPHP was recently launched; it provides a middleware system for anything using Symfony's HttpKernelInterface (Symfony, Silex, ezPublish, etc).

inanimatt
  • 692
  • 5
  • 9