rxthunder/eventstore

RxThunder 的事件存储库

0.2.0 2019-10-21 14:05 UTC

This package is auto-updated.

Last update: 2024-09-22 01:33:50 UTC


README

Latest Stable Version Total Downloads License

Build

安装

composer install rxthunder/eventstore

设置

首先,您必须在您的 .env 文件中添加新的机密信息

# .env
EVENTSTORE_DSN_HTTP=
EVENTSTORE_DSN_TCP=

然后配置要注入到容器中的新参数

# config/parameters.php

$container->setParameter('eventstore.http', getenv('EVENTSTORE_DSN_HTTP'));
$container->setParameter('eventstore.tcp', getenv('EVENTSTORE_DSN_TCP'));

复制粘贴所需控制台配置

# config/services.php

require_once __DIR__ . '/../vendor/rxthunder/eventstore/config/services.php';

use RxThunder\EventStore\Console\EventStoreConsole;
use RxThunder\EventStore\Console\EventStoreSetupConsole;

$container->register(EventStoreConsole::class)
    ->setPublic(true)
    ->setAutowired(true)
    ->setAutoconfigured(true)
;

$container->register(EventStoreSetupConsole::class)
    ->setPublic(true)
    ->setAutowired(true)
    ->setAutoconfigured(true)
;

或者如果您更喜欢,可以包括所有现有和未来的控制台

# config/services.php

require_once __DIR__ . '/../vendor/rxthunder/eventstore/config/services.php';
require_once __DIR__ . '/../vendor/rxthunder/eventstore/config/consoles.php';

提示

如果您不需要使用相关控制台自动设置 EventStore 投影,则不要注册 EventStoreSetupConsole

这避免了配置以下章节的需要。

PHP-HTTP

这是最后一步,仅当您想使用 EventStoreSetupConsole 时。

如果您还没有在 DI 中添加 HTTP 客户端实现(PSR-18),请在此处找到现有实现列表

同样,HTTP 请求必须由您喜欢的工厂构建,您可以在 packagist 上找到一些现成的库。

之后,只需将您喜欢的客户端和工厂通过接口进行别名设置。

$container->setAlias(\Psr\Http\Client\ClientInterface::class, ClientImplementation::class);
$container->setAlias(Http\Message\RequestFactory::class, FactoryImplementation::class);

大功告成

您有了新的控制台!

php vendor/bin/thunder