reestyle / peavents
基本事件处理器
dev-master
2020-08-09 00:00 UTC
Requires
- php: 7.1.0
This package is auto-updated.
Last update: 2024-09-29 05:55:50 UTC
README
介绍
Peavents代表PHP事件 - 有一些特别之处。我觉得加上“豌豆”这个词会很有趣... :)
Peavents是一个基本的事件系统。有点像钩子系统,但略有不同。
要求
- PHP 7.0+
此项目使用了数据类型类型提示和返回值类型。这两个类都是基于ArrayObject类。
安装
使用composer
$ composer require reestyle/peavents
请记住使用自动加载器。
基本用法
$registry = \Peavents\Registry::instance(); $event = $registry->make('event_name'); $event ->setParams(['hello world']) ->attach(function($a) { print $a; }) ->attach(function($a) { print ' - and another ' . $a; }); $registry->raise('event_name');