sy / event
一个简单的事件分发器,PSR14 兼容
1.1.0
2021-09-27 12:28 UTC
This package is auto-updated.
Last update: 2024-08-27 19:31:57 UTC
README
PSR-14 兼容的事件分发器,提供分发事件和监听分发事件的特性
安装
使用以下命令安装最新版本
$ composer require sy/event
基本用法
<?php use Sy\Event\EventDispatcher; use Sy\Event\Event; $eventDispatcher = new EventDispatcher(); // Add an event listener on an event named "myEvent" $eventDispatcher->addListener('myEvent', function (object $event) { echo 'An event occurs: ' . $event->getName(); }); // Dispatch an event called "myEvent" $eventDispatcher->dispatch(new Event('myEvent'));