sajad torkamani

When is it dispatched

Dispatched after the control has been resolved but before it’s executed.

Use cases

  • Initialize things later needed by the controller (e.g., param converters).
  • Change the controller entirely.


use Symfony\Component\HttpKernel\Event\ControllerEvent;

public function onKernelController(ControllerEvent $event)
    // ...

    // the controller can be changed to any PHP callable

List event listeners

php bin/console debug:event-dispatcher kernel.controller

Sources / related

Tagged: Symfony