Symfony events: kernel.response reference
20 November 2022 (Updated 20 November 2022)
When is it dispatched?
The kernel.response
event is dispatched after the controller or a kernel.view
listener returns a Response
object.
Use cases
- Modify or replace the response (e.g., add/modify HTTP headers or add cookies).
Event class
Listeners to kernel.response
will receive a ResponseEvent
object.
Example
use Symfony\Component\HttpKernel\Event\ResponseEvent;
public function onKernelResponse(ResponseEvent $event)
{
$response = $event->getResponse();
// ... modify the response object
}
List event listeners
php bin/console debug:event-dispatcher kernel.response
- Symfony kernel events reference
- Symfony events: kernel.request reference
- Symfony events: kernel.controller reference
- Symfony events: kernel.controller_arguments reference
- Symfony events: kernel.view reference
- Symfony events: kernel.response reference
- Symfony events: kernel.finish_request reference
- Symfony events: kernel.terminate reference
- Symfony events: kernel.exception reference
Tagged:
Symfony
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment