innmind/installation-monitor

简单的套接字,用于累积和分发系统事件

3.1.0 2021-02-15 17:05 UTC

This package is auto-updated.

Last update: 2024-09-16 01:24:06 UTC


README

Build Status codecov Type Coverage

一个用于监听并重新分发来自/到其他应用程序的事件的工具。

这在安装应用程序时让应用程序进行自我配置很有用。例如,一个依赖于应用程序A的应用程序B,A可以向这个工具发送一个事件,当B的安装开始时,它可以要求这个工具发送它记录的所有事件。

安装

composer require innmind/installation-monitor

用法

第一步是启动将聚合事件的服务器

installation-monitor oversee --daemon

然后您可以从您的应用程序发送一个类似的事件

use function Innmind\InstallationMonitor\bootstrap;
use Innmind\InstallationMonitor\Event;
use Innmind\Immutable\{
    Map,
    Sequence,
};

$client = bootstrap()['client']['ipc']();
$client->send(
    new Event(
        new Event\Name('foo'),
        $payload = Map::of('string', 'scalar|array')
    ),
    new Event(
        new Event\Name('bar'),
        $payload = Map::of('string', 'scalar|array')
    )
    // etc...
);
// or
$client->events(); // Sequence<Event> all the events recorded by the server