ksfraser/event
最新稳定版本:v1.0.0
Composer 安装命令:
composer require ksfraser/event
包简介
PSR-14 compliant event system with extended listener management
README 文档
README
A PSR-14 compliant event system with extended listener management capabilities for PHP applications.
Features
- PSR-14 Compliance: Full compatibility with PSR-14 Event Dispatcher standard
- Extended Listener Management: Additional methods for advanced listener control
- Type-Safe: Full PHP 8.1+ type declarations and strict typing
- Singleton Pattern: Convenient global access through EventManager
- Plugin Support: Built-in support for plugin lifecycle events
Installation
composer require ksfraser/event
Basic Usage
use Ksfraser\Event\EventManager; use Ksfraser\Event\MyCustomEvent; // Dispatch an event EventManager::dispatchEvent(new MyCustomEvent($data)); // Add a listener EventManager::on('user.created', function($event) { // Handle user creation });
Creating Custom Events
<?php use Ksfraser\Event\Event; class UserCreatedEvent extends Event { public function __construct( public readonly int $userId, public readonly string $email ) {} }
Advanced Listener Management
use Ksfraser\Event\EventManager; // Add multiple listeners EventManager::on('order.processed', [$orderService, 'sendConfirmation']); EventManager::on('order.processed', 'sendOrderNotification'); // Get listener provider for advanced management $listenerProvider = EventManager::getInstance()->getListenerProvider();
Requirements
- PHP 8.1+
- PSR-14 Event Dispatcher interface
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
This project is licensed under the GPL v3 License.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2026-02-16