use Symfony\Component\EventDispatcher\EventDispatcher; use App\Events\UserCreatedEvent; use App\Listeners\SendWelcomeEmailListener; $dispatcher = new EventDispatcher(); $dispatcher->addListener(UserCreatedEvent::class, [new SendWelcomeEmailListener(), 'handle']); $user = new User(); // code to create a user $event = new UserCreatedEvent($user); $dispatcher->dispatch(UserCreatedEvent::class, $event);In this example, we're listening for the `UserCreatedEvent` and calling the `SendWelcomeEmailListener` when it's triggered. We then dispatch the event with the relevant data. By using the Symfony EventDispatcher component, we can easily set up and manage event listening in our PHP applications, making them more flexible and easier to maintain.