定制 wallsfantasy/event-store-laravel-package 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wallsfantasy/event-store-laravel-package

Composer 安装命令:

composer require wallsfantasy/event-store-laravel-package

包简介

A package for using the event store in a Laravel project

README 文档

README

This package presents the necessary tools to leverage Prooph Event Stores inside a Laravel project.

An example of how to use this project can be found at the ProophessorDo Laravel example.

Features

  • Support PDO event stores out of the box
  • Provide commands for working with projections
  • Bind repositories to class name and optional interface
  • Support custom projection manager and event store resolvers
  • Support snapshot stores
  • Add migrations for streams, projections and snapshots

Installation

composer require camuthig/laravel-event-store-package

Setup

Publish the Config

php artisan vendor:publish

Include the Provider

The package will automatically be discovered by Laravel when installed, no changes to include the service provider are needed.

Usage

Event Store

Each event store is bound in a number of ways.

  • Each store is bound to the class it implements
  • The default store will also be bound the the EventStore interface

Additionally, each store can be retrieved by name, as found in the configuration file, using the EventStoreManager or EventStore facade.

<?php

use Camuthig\EventStore\Package\EventStoreManager;
use Prooph\EventStore\EventStore;
use Prooph\EventStore\Pdo\MySqlEventStore;

class MyController
{
    public function __construct(EventStore $eventStore, MySqlEventStore $mySqlEventStore, EventStoreManager $eventStoreManager) 
    {
        // The EventStore interface will be bound to the "default" store
        $eventStore->fetchCategoryNames(null);
        
        // Each event store is also bound to the class it is an instance of
        $mySqlEventStore->fetchCategoryNames(null);
        
        // The EventStoreManager is also bound into the application
        
        // The default event store can be retrieved from the EventStoreManager
        $eventStoreManager->store()->fetchCategoryNames(null);
        
        // Or you can fetch any store by name
        $eventStoreManager->store('postgres')->fetchCategoryNames(null);
        
        // Or you can work wih the manager by facade
        \Camuthig\EventStore\Package\Facade\EventStore::store()->fetchCategoryNames(null);
    }
}

Repositories

Each repository will be bound to the repository_class defined in the configuration file. Additionally, you can provide a repository_interface. If provided, the instance will also be bound to the interface, which can be used for dependency injection.

Projection Managers

Projection managers are configured and bound to the Artisan application. The package defines a number of commands to work with the projection managers to accomplish tasks like:

  • Running a projection
  • Deleting a projection
  • Reset a projection
  • Stopping a projection
  • Showing the status of a projection
  • Showing the event stream positions for a projection
  • Listing all available projections

To use the commands, first start a projection by name:

php artisan event-store:projection:run users

While the projection is running, you can delete/reset/stop it:

php artisan event-store:projection:reset users

php artisan event-store:projection:delete -w users

php artisan event-store:projection:stop users

Configuration

Plugins

A list of globally available Event Store plugins. Each entry will be the registered service ID for the plugin. The application will app()->make(<name>) for each entry in the list.

[
    App\EventStore\Plugins\MyPlugin::class,
]

Metadata Enrichers

A list of globally available Event Store metadata enrichers. Each entry will be the registered service ID for the plugin. The application will app()->make(<name>) for each entry in the list.

[
    App\EventStore\Enrichers\MyEnricher::class,
]

Stores

A list of all defined event stores in the system. The plugin currently supports the following stores out of the box:

  • MySQL
  • MariaDB
  • PostgreSQL

Each Event Store can configure:

  • persistence_strategy The class name or service ID of the persistence strategy
  • load_batch_size The number of events a query should return in a single batch. Default is 1000.
  • event_streams_table The event stream table to use. The default is event_streams.
  • message_factory The message factory to use. Default is FCQNMessageFactory
  • disable_transaction_handling Boolean to turn off transaction handling. The default is false.
  • action_event_emitter The default is ProophEventActionEmitter.
  • wrap_action_event_emitter The default is true.
  • metadata_enrichers A list of metadata enrichers to add to the store.
  • plugins A list of plugins
  • to add to the store.

Repositories

A list of all defined repositories. Each repository should be indexed using a name. Each repository should define:

  • store The key of the store to use. Valid values are any key in the stores array above.
  • repository_interface An optional interface to alias the repository with. This can be used to support dependency injection in your classes.
  • repository_class The FQCN or service ID for the repository class.
  • aggregate_type The FQCN for the aggregate this store maintains or the array mapping.
  • aggregate_translator The translator for the aggregate. Defaults to \Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator.
  • stream_name The stream name.
  • one_stream_per_aggregate Set this to true for an aggregate stream strategy. Default is false.

Projection Managers

A list of all configured projection managers. Each manager should define:

  • store The name of the store. One of mysql, maria_db or postgres
  • event_streams_table Defaults to event_streams
  • projections_table Defaults to projections
  • projections A list of all projections in this manager.

Each projection should define:

  • connection The name of the connection to use. This is an optional configuration. Defaults to the same connection as the store if not provided.
  • read_model The FQCN or service ID of the projection read model. This is an optional value, only necessary for Read Model projections.
  • projection The FQCN or service ID of the projection.

wallsfantasy/event-store-laravel-package 适用场景与选型建议

wallsfantasy/event-store-laravel-package 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 08 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 wallsfantasy/event-store-laravel-package 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wallsfantasy/event-store-laravel-package 我们能提供哪些服务?
定制开发 / 二次开发

基于 wallsfantasy/event-store-laravel-package 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 27
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-08-27