This is the long-form documentation for
initphp/events. The package
README covers the same material at a glance; these chapters go into
the details.
If you are new to the package, read in order:
- Getting started — install it, run the smallest possible example, learn the three classes you will touch.
- The
Eventsfacade — the static application-wide dispatcher, when to use it, when not to. - Using
EventEmitterdirectly — the low-level primitive: instantiate,on/once/emit, no global state. - Priorities and ordering — the
full contract for what runs when, including how
once()interacts with the priority queue and the case-insensitive event-name rule. - Once-listeners, removal, and cleanup —
once,off,removeAllListeners,clearOnceListeners, and the guarantees each one gives you. - Debug and simulate modes — opt-in instrumentation for dry-runs and timing measurements.
- Migrating from
initphp/event-emitter— the BC alias, theemit()bug fix, the v2.0 priority-sort fix, what to change and what to leave alone. - Recipes — concrete patterns: plugin systems, request lifecycle hooks, WordPress-style action / filter hooks, testing strategies.
- API reference — every public method, every exception, every constant.
Spotted a gap or something that doesn't match what the code actually does? Please open an issue — the documentation tries to match the code character for character, and divergence is a bug we want to hear about.