我正在寻找一种方法来为Symfony2上的应用程序创建类似Django的中间件 。 基本上,我需要在处理每个 request之前对Controllers进行预处理,并在Controllers之后对每个 response后处理,但是在它提供给用户之前。
有什么想法吗?
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?
最满意答案
Symfony2中不需要中间件。 有些事情叫做内核事件。
http://symfony.com/doc/current/book/internals.html#events
你可能想看看kernel.request和kernel.response
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
Symfony2中间件(Symfony2 middleware)我正在寻找一种方法来为Symfony2上的应用程序创建类似Django的中间件 。 基本上,我需要在处理每个 request之前对Controllers进行预处理,并在Controllers之后对每个 response后处理,但是在它提供给用户之前。
有什么想法吗?
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?
最满意答案
Symfony2中不需要中间件。 有些事情叫做内核事件。
http://symfony.com/doc/current/book/internals.html#events
你可能想看看kernel.request和kernel.response
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
发布评论