Download the PHP package phpdot/event without Composer
On this page you can find all versions of the php package phpdot/event. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package event
phpdot/event
A PSR-14 event dispatcher where the #[Listener] attribute is the registration — no central config,
no service providers. Listeners are ordered, can run synchronously or be queued for async dispatch, and
the listener set is resolved through a repository so it can be persisted and toggled at runtime.
Table of Contents
- Requirements
- Installation
- Usage
- Architecture
- Testing
- License
Requirements
| Requirement | Constraint |
|---|---|
| PHP | >= 8.5 |
phpdot/attribute |
^0.4 |
phpdot/console |
^0.4 |
phpdot/contracts |
^0.4 |
psr/container |
^2.0 |
psr/event-dispatcher |
^1.0 |
symfony/console |
^8.0 |
Installation
Usage
Events and listeners
An event is any class. A handler declares what it handles with #[Listener] — the attribute is the
registration:
Discovery and wiring
The attribute is the whole registration — AttributeListenerDiscovery scans with
phpdot/attribute and answers the entries boot loads. Nothing else re-states the binding:
Every service carries #[Singleton]/#[Binds] — in a phpdot application the PSR-14 interfaces
resolve from the container; event:list prints the discovered surface (event, listener, order,
mode) with --event <name> to filter.
Fail-loud at boot: a declared event that is not a class, or a priority outside 0-10, is a
ListenerException naming the listener — never a silent listener that never fires.
Dispatching
Dispatch runs two phases: every sync listener first, in order (lowest first), with
StoppableEventInterface semantics honored per PSR-14 — then every async listener is handed to
the AsyncDispatcherInterface in order. Propagation stop halts everything after it, async
listeners included; an async listener ordered before the stopper still publishes. Every dispatch
carries a span (event.dispatch on the event channel) with one event.listener event per
listener — observability through phpdot/contracts, per the v0.3.0 doctrine.
Async listeners
A listener marked #[Listener(..., async: true)] is handed to the injected
AsyncDispatcherInterface instead of running inline. SyncOnlyDispatcher is the shipped
fallback: publish means run, immediately, inline after the sync phase — priority is ignored
(there is no queue to order) and a handler failure is a ListenerException (it ran — never
disguised as a queue failure). Bind a queue backend when timing matters — whichever broker the
application installed; the dispatcher publishes, the application's worker
consumes.
Architecture
EventDispatcher asks the ListenerProvider for the ordered listeners of an event, resolves each
handler class through the container, and either invokes it synchronously or hands it to the async
dispatcher. The listener set itself comes from a repository, so it can be discovered from attributes,
persisted, and toggled without touching code.
Testing
License
MIT.
This repository is a read-only mirror, generated by CI from phpdot/monorepo. Pull requests and issues belong in the monorepo.
All versions of event with dependencies
phpdot/attribute Version ^0.5
phpdot/console Version ^0.5
phpdot/contracts Version ^0.5
psr/container Version ^2.0
psr/event-dispatcher Version ^1.0
symfony/console Version ^8.0