indigophp / supervisor-event
v0.1.0
2015-01-04 13:59 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- guzzlehttp/streams: >=2.0.0
- henrikbjorn/phpspec-code-coverage: ~1.0.0
- phpspec/phpspec: ~2.1.0
Suggests
- guzzlehttp/streams: Used by Stream listener
This package is not auto-updated.
Last update: 2022-02-01 12:43:18 UTC
README
弃用通知
此包已移动至SupervisorPHP。
有关详细信息,请参阅 http://supervisorphp.com
Indigo Supervisor Event
在PHP中监听Supervisor事件。
安装
通过Composer
$ composer require indigophp/supervisor-event
使用方法
Supervisor有一个很好的功能:通知(你的监听器)关于它的事件。
主要入口点是Listener
。监听器在主监听逻辑中等待Handler
。当发生事件时,处理器会接收到Notification
。
use Indigo\Supervisor\Event\Listener\Standard; use Indigo\Supervisor\Event\Handler\Callback; use Indigo\Supervisor\Event\Notification; $handler = new Callback(function(Notification $notification) { echo $notification->getHeader('eventname'); }); $listener = new Standard; $listener->listen($handler);
当前可用的监听器
- 标准:监听标准输入流,写入标准输出
- Guzzle:使用
StreamInterface
提供读取/写入的简单接口
此外,您还可以使用两个异常来控制监听器本身
Indigo\Supervisor\Exception\StopListener
:表示Listener
应该停止监听进一步的事件。Indigo\Supervisor\Exception\EventHandlingFailed
:表示处理事件失败,Listener
应该返回失败响应。
任何其他未处理的异常/错误都将导致监听器停止。
有关事件的更多信息,请查看Supervisor文档。
测试
$ phpspec run
贡献
有关详细信息,请参阅CONTRIBUTING。
鸣谢
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。