ghostwriter/event-dispatcher
最新稳定版本:6.0.2
Composer 安装命令:
composer require ghostwriter/event-dispatcher
包简介
Event Dispatcher implementation.
README 文档
README
Provides an Event Dispatcher implementation for PHP.
Installation
You can install the package via composer:
composer require ghostwriter/event-dispatcher
Star ⭐️ this repo if you find it useful
You can also star (????) this repo to find it easier later.
Usage
Registering and dispatching an Event Listener.
use Ghostwriter\EventDispatcher\EventDispatcher; use Ghostwriter\EventDispatcher\ListenerProvider; // Create an event class final class ExampleEvent { } // Create an Event Listener final class ExampleEventListener { public function __invoke(ExampleEvent $event): void { // Handle the event, e.g., print the event class name // echo $event::class; } } // Create a ListenerProvider $listenerProvider = ListenerProvider::new(); // or new ListenerProvider(Container::getInstance()) // Bind the Listener to the Event $listenerProvider->listen(ExampleEvent::class, ExampleEventListener::class); // Create an EventDispatcher $dispatcher = EventDispatcher::new($listenerProvider); // or new EventDispatcher($listenerProvider) // Dispatch the Event. $event = $dispatcher->dispatch(new ExampleEvent()); // Assert the Event is the same as the dispatched Event assert($event instanceof ExampleEvent);
Changelog
Please see CHANGELOG.md for more information what has changed recently.
Security
If you discover any security related issues, please email nathanael.esayeas@protonmail.com or create a Security Advisory instead of using the issue tracker.
License
The BSD-4-Clause. Please see License File for more information.
统计信息
- 总下载量: 4.53M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 14
- 推荐数: 0
其他信息
- 授权协议: BSD-4-Clause
- 更新时间: 2026-01-04