Download the PHP package mildabre/event-dispatcher without Composer
On this page you can find all versions of the php package mildabre/event-dispatcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mildabre/event-dispatcher
More information about mildabre/event-dispatcher
Files in mildabre/event-dispatcher
Package event-dispatcher
Short Description Simple event dispatcher for Nette based applications.
License MIT
Informations about the package event-dispatcher
Event Dispatcher
Simple, fresh, and modern event dispatcher with attribute-based event listener registration for Nette Framework applications.
Features
- Attribute-based registration - Use PHP 8 attributes to mark events and listeners
- Simple API - Minimal configuration, maximum productivity
- Nette DI integration - Seamless integration with Nette Dependency Injection
- Lightweight - No bloat, just what you need
- Event Listener Discovery - Automatic listener registration
Installation
Install via Composer:
Configuration
Register the extension in your common.neon:
Optional dispatch disabling:
Define an Event
Create an event as value object (final readonly class) with class and mark it with the #[Event] attribute.
Create an Event Listener
Create a listener class with a handle() method that accepts your event:
Dispatch Events
Inject the EventDispatcher and dispatch your events:
How It Works
- Event Classes must be annotated with
#[Event]attribute - Listener Classes must be tagged with
#[EventListener]attribute (frommildabre/service-discovery) - Listener Methods must be named
handle()and accept exactly one parameter of the event class type - Auto-registration happens automatically via Nette DI - listeners are discovered and registered at compile time
Architecture
The event dispatcher follows a simple but powerful architecture:
Requirements
- PHP >= 8.1
- nette/di ^3.1
- nette/schema ^1.2
- mildabre/service-discovery ^0.1
License
This project is licensed under the MIT License.
All versions of event-dispatcher with dependencies
nette/di Version ^3.1
nette/schema Version ^1.2
mildabre/service-discovery Version ^0.1