use Symfony\Component\EventDispatcher\EventDispatcher; use App\EventListener\MyListener; $dispatcher = new EventDispatcher(); $dispatcher->addListener('my.event', [new MyListener(), 'onEvent']);
use Symfony\Component\EventDispatcher\EventDispatcher; use App\Event\MyEvent; $dispatcher = new EventDispatcher(); $dispatcher->dispatch('my.event', new MyEvent());This code dispatches a 'my.event' event with a MyEvent object as the event object. In conclusion, the EventDispatcher component in Symfony provides a highly configurable and flexible way to manage events in your application. The EventDispatcherInterface is one of many packages in Symfony\Component\EventDispatcher that can be used to expand the capabilities of the event dispatcher.