indigophp/supervisor-event

此包已被废弃,不再维护。作者建议使用 supervisorphp/event 包。

在PHP中监听Supervisor事件

v0.1.0 2015-01-04 13:59 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:43:18 UTC


README

弃用通知

此包已移动至SupervisorPHP。

https://github.com/supervisorphp/event

有关详细信息,请参阅 http://supervisorphp.com

Indigo Supervisor Event

Latest Version Software License Build Status Code Coverage Quality Score HHVM Status Total Downloads Dependency Status

在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)。有关更多信息,请参阅许可文件