摘要： 本文讲的是Symfony: Log outgoing responses with kernel events， One of the nicest features of Symfony2 is the Request/Response paradigm for processing a HTTP request and then sending
One of the nicest features of Symfony2 is the Request/Response paradigm for processing a HTTP request and then sending a response back to a client. At a high level, Symfony’sHttpFoundationcomponent provides an object oriented abstraction to easily deal with HTTP requests and generate responses to send back to a client. Assuming application code correctly uses HttpFoundation, it will only interact with request variables through the Request class, as opposed to $_REQUEST, and only send output using the Response class, as opposed to an “echo”. Because of this contract, the framework as a whole makes it easy to manipulate responses before they’re sent back to a client.
A typical use case that leverages this would be logging API responses before they’re sent back to a client. As much as an API might beRESTful, at some point it’s easier to debug things when you can see the responses that clients have been receiving. OK great so how do you do it? It’s actually pretty straightforward, just create a class to receive the “kernel.response” event and register it as a service with the appropriate tags:
|android-PHP symfony1...||linux防火墙iptables常用sh...||httpclient GET 得到的lo...|
|问题描述 PHP symfony1.1检测设备 需要检测设备是Android还是iPhone。使用下面的代码...||...net/ipv4/conf/*/log_martians; do echo 1 > $i; done ...||...e()+" "+header.getValue()); } CloseableHttpResponse...|