explaingit

symfony/event-dispatcher

8,547PHPAudience · developerComplexity · 2/5Setup · easy

TLDR

A standalone PHP library that lets different parts of an application communicate by dispatching named events and registering listeners, so modules stay independent and don't need to call each other directly.

Mindmap

mindmap
  root((EventDispatcher))
    Core Concept
      Named events
      Registered listeners
      Loose coupling
    Usage
      Dispatch events
      Register listeners
      Set priorities
    Integration
      Standalone package
      Any PHP project
      Full Symfony too
    Examples
      User registered
      Email triggers
      Analytics hooks
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add an event system to any PHP project so modules can react to application events without importing or calling each other.

USE CASE 2

Trigger a named event after creating a user account and attach separate listeners for sending email, logging, and assigning default roles.

USE CASE 3

Extract business logic into isolated listeners that fire on domain events, making a PHP application easier to test and extend.

Tech stack

PHPSymfony

Getting it running

Difficulty · easy Time to first run · 30min
No license information was mentioned in the description.

In plain English

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.

Copy-paste prompts

Prompt 1
Using symfony/event-dispatcher in a plain PHP project (no full Symfony), show me the minimal setup to dispatch a custom OrderPlaced event and register two listeners.
Prompt 2
How do I set listener priorities in symfony/event-dispatcher so that one listener always runs before another on the same event?
Prompt 3
I want to stop other listeners from running after one listener handles an event in symfony/event-dispatcher. Show me how to use stopPropagation inside a listener.
Open on GitHub → Explain another repo

← symfony on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.