stougeiro / event-contract
Minimal event contract defining lightweight interfaces for dispatching string-based events and registering listeners in modular PHP applications.
Fund package maintenance!
Requires
- php: >=8.2
Requires (Dev)
- phpstan/phpstan: ^2.2
This package is auto-updated.
Last update: 2026-08-19 19:37:14 UTC
README
Event Contract
Minimal event contract package defining the core interfaces for a plug-and-play event system. Provides a lightweight EventManagerInterface for dispatching string‑based events and registering listeners, along with a simple EventListenerInterface for building modular, high‑performance PHP applications.
✨ Features
-
Lightweight event dispatcher
Dispatches string-based events with zero overhead and no required event classes. -
Simple listener model
Listeners are invokable classes, allowing full freedom for dependency injection. -
Plug-and-play architecture
Any event implementation can be swapped without changing application code. -
Framework-agnostic
Works with any PHP project, from microframeworks to full-stack applications. -
High performance
Minimal abstractions designed for fast execution, ideal for shared hosting environments.
📦 Installation
Install via Composer:
composer require stougeiro/event-contract
🔧 Implementations
Below is a list of known implementations maintained by the community.
stougeiro/event
Repository: https://github.com/stougeiro/event
🧠 Why?
Because event systems don’t need to be complex. This contract defines the smallest possible interface for an event dispatcher, enabling developers to build fast, modular applications without the overhead of class‑based events or heavy abstractions.
By using simple string identifiers and invokable listeners, any event engine can be implemented — synchronous, asynchronous, queued, file‑based, or custom — while keeping a consistent interface across the entire application.
This promotes flexibility, testability, and high performance, especially in environments with limited resources.
🤝 Contributions
Contributions are welcome. Feel free to open issues or submit pull requests.