sajad torkamani

In a nutshell

The Symfony framework is essentially an HTTP request-response framework. While handling an incoming HTTP request, the framework dispatches some events that you can use to modify the request or response.

Each event dispatched by the HttpKernel component is defined as a constant on the KernelEvents class. Each event listener is passed a single argument, which is some subclass of KernelEvent, which gives you the following information:

  • getRequestType() – Returns the type of the request (e.g., HttpKernelInterface::MAIN_REQUEST or HttpKernelInterface::SUB_REQUEST)
  • getKernel() – Returns the Kernel handling the request.
  • getRequest() – Returns the current Request being handled.
  • isMainRequest() – Checks if this is a main request.

Events reference

NameKernelEvents ConstantArgument passed to the listener
kernel.requestKernelEvents::REQUESTRequestEvent
kernel.controllerKernelEvents::CONTROLLERControllerEvent
kernel.controller_argumentsKernelEvents::CONTROLLER_ARGUMENTSControllerArgumentsEvent
kernel.viewKernelEvents::VIEWViewEvent
kernel.responseKernelEvents::RESPONSEResponseEvent
kernel.finish_requestKernelEvents::FINISH_REQUESTFinishRequestEvent
kernel.terminateKernelEvents::TERMINATETerminateEvent
kernel.exceptionKernelEvents::EXCEPTIONExceptionEvent

Sources

Tagged: Symfony