gitmyhub

event-dispatcher

PHP ★ 8.5k updated 12d ago

Provides tools that allow your application components to communicate with each other by dispatching events and listening to them

This repository contains the EventDispatcher component, one of the building blocks of the Symfony PHP framework. It is a library that lets different parts of an application talk to each other without being directly connected.

The basic idea is that one piece of code can announce that something happened by dispatching a named event. Other pieces of code can register themselves as listeners for that event, and they will be called automatically when it fires. This pattern keeps components loosely coupled: the code that triggers the event does not need to know anything about the code that reacts to it.

For example, an application might dispatch a "user registered" event after creating a new account. Separate listeners could then send a welcome email, update analytics, or assign default settings, each in their own isolated code block, without the registration logic knowing any of that exists.

This component is a standalone package extracted from the Symfony framework, which means you can use it in any PHP project, not just those built with Symfony. The README is minimal because the full documentation lives on the Symfony website, where it covers configuration, priorities, event objects, and practical usage examples.

The component is maintained as part of the main Symfony repository. Bug reports and contributions go there rather than to this standalone mirror.