Download the PHP package componenta/event without Composer
On this page you can find all versions of the php package componenta/event. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download componenta/event
More information about componenta/event
Files in componenta/event
Package event
Short Description PSR-14 compliant event dispatcher with prioritized and composite listener providers
License MIT
Informations about the package event
Componenta Event
Minimal PSR-14 event dispatcher with prioritized and composite listener providers. Mutable providers with unsubscribe tokens, immutable dispatcher.
Русская документация
Installation
Requirements
- PHP 8.4+
psr/event-dispatcher^1.0
Related Packages
| Package | Why it matters here |
|---|---|
psr/event-dispatcher |
Defines the PSR-14 dispatcher and listener-provider interfaces. |
componenta/auth |
Can publish authentication and session lifecycle events. |
componenta/cqrs |
Can publish command lifecycle events through EventMiddleware. |
componenta/error-handler |
Can report errors through listeners. |
componenta/di |
Can create listeners from the application container. |
Quick Start
Components
EventDispatcher
Final, readonly PSR-14 dispatcher. The provider reference is shared — listeners registered later are visible to all dispatches.
Events implementing Psr\EventDispatcher\StoppableEventInterface halt propagation when isPropagationStopped() becomes true. An already-stopped event skips all listeners.
ListenerProvider
Plain listener registry keyed by event class. addListener() returns an unsubscribe closure.
PrioritizedProvider
Listeners are dispatched in priority order. Sorting is lazy and cache-aware — adding a listener after a dispatch invalidates the cached order.
Priorities are resolved in this order: explicit $priority argument → PrioritizedListenerInterface::$priority → 0. Listeners with equal priority are dispatched in registration order (stable sort).
PrioritizedListenerInterface
Invokable listeners can expose their own priority:
CompositeProvider
Aggregates multiple providers into one. contains() is recursive; has() works across EventTypeAwareProviderInterface children.
Bulk Registration
Patterns
One-shot listener
Scoped subscription
Reference
| Symbol | Purpose |
|---|---|
EventDispatcher |
PSR-14 dispatcher, final readonly |
ListenerProvider |
Plain keyed-by-event-class registry |
PrioritizedProvider |
Priority-ordered registry with lazy sort |
CompositeProvider |
Aggregate of child providers, recursive contains |
EventTypeAwareProviderInterface |
Contract for providers that expose has(eventType) |
PrioritizedListenerInterface |
Listener-side priority declaration |
SortMode |
ASC / DESC for PrioritizedProvider |
All mutable providers expose: addListener, addListeners, removeListener, contains, has. addListener returns an unsubscribe Closure.
License
MIT