miguelsaddress/pesy
Composer 安装命令:
composer require miguelsaddress/pesy
包简介
Pesy: PHP Event System
README 文档
README
This is an event system that allows you to broadcast events that will be handled by different entities than the emitter.
Paths
Paths can be unique, such as "myPath:extra:thing" or it can contain a wildcard * to show it handles whatever subevent path such as you will see in the case of another:path:* which will handle all subpaths like another:path:like:this but IT WILL NOT HANDLE paths like another:path
Initialization:
Create a Handler's centre. It will be the main holder of the Handlers. Technically, though any EventHandlerList would do...
$handlersCentre = HandlersCentre::getWithHandlers(array( 'TextFileDump' => new TextFileDumpSampleHandler(array("sample:*")), 'OtherTextFileDump' => new TextFileDumpSampleHandler(array("another:path:*")) ));
Once you have the handlers centre or your list, you can create your emitter, that will emit to the list of handlers registered in the handlers list passed by parameter
$eventEmitter = new EventEmitter($handlersCentre->getList());
Now, whereever in your code, you can create an event and broadcast it. If th path of the event is handled by any of the handlers, it will be processed. Otherwise, it will be ignored
$e = new TestEvent(); $e->setPath("sample:path"); $e->addData("key1", "value1"); $e->addData("key2", array(1,2,3)); $eventEmitter->broadcast($e);
This will not be handled, since no handler is listening for this path wontBeHandled
$e = new TestEvent(); $e->setPath("wontBeHandled"); $e->addData("wontAppear", "in text file"); $eventEmitter->broadcast($e);
As told before, this will be handled by the OtherTextFileDump handler
$e = new TestEvent(); $e->setPath("another:path:like:this"); $e->addData("will appear", "in text file"); $eventEmitter->broadcast($e);
Contact
You can contact me at my twitter: @miguelsaddress
miguelsaddress/pesy 适用场景与选型建议
miguelsaddress/pesy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 miguelsaddress/pesy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 miguelsaddress/pesy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-26