定制 desmart/laravel-event-sourcing 二次开发

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

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

desmart/laravel-event-sourcing

Composer 安装命令:

composer create-project desmart/laravel-event-sourcing

包简介

Laravel bindings for DeSmart Event Sourcing package

README 文档

README

Simple Laravel implementation of event sourcing mechanism.

Latest version Build Status Software License

Be advised: this package is work in progress and some breaking changes may appear on the way.

Package realizes concept of event sourcing with Laravel framework. Package consists of two main elements: implementation of database-like event store and projection manager.

Event store is a append-only storage dedicated for storing events. Projection manager allows to register projections and update them with generated stream of events.

Installation

To install the package via Composer, simply run the following command:

composer require desmart/laravel-event-sourcing

In order to use provided event store implementation, register service provider in your config/app.php file:

'providers' => [
    // ...
    
    DeSmart\EventSourcing\Laravel\EventStore\ServiceProvider::class,
]

In order to use projection manager, register service provider in your config/app.php file:

'providers' => [
    // ...
    
    DeSmart\EventSourcing\Laravel\Projections\ServiceProvider::class,
]

After registering service provider(s), run artisan command to publish configuration files:

php artisan vendor:publish

Configuration

Package adds two configuration files: event-store.php and read-model.php.

event-store.php

Here you can configure:

  • which connection will be used to connect with your event store,
  • which event's payload serializer will be used.
return [
    /*
    |-------------------------------------------------------------------------------------
    | Database Connection For Event Store
    |-------------------------------------------------------------------------------------
    |
    | Specify which database connection should be used for storing events in events store.
    | All database connections can be found in config/database.php configuration file.
    |
    */

    'connection' => null,

    /*
    |-------------------------------------------------------------------------------------
    | Event Store Payload Serializer
    |-------------------------------------------------------------------------------------
    |
    | Serializer used for serializing/deserializing event and it's payload.
    |
    | Payload is usually of array type. It is sufficient to store payload in 
    | JSON format.
    |
    | Supported serializers: 
    | - 'JsonSerializer' -> use for event store that does not have automatic json serialization/deserialization, like mysql databases
    | - 'ArraySerializer -> use for event store that has automatic json serialization/deserialization, like mongodb databases
    |
    */
    
    'serializer' => \DeSmart\EventSourcing\Laravel\EventStore\Serializers\JsonSerializer::class
];

read-model.php

Here you can register all projections that should be notified with stream of events.

return [
    /*
    |--------------------------------------------------------------------------
    | Read Model Projections
    |--------------------------------------------------------------------------
    |
    | Array of projection classes.
    |
    | These projections will be notified about saved stream of events and they
    | can react with read model updates.
    |
    */
    
    'projections' => []
];

Event store implementation

This package's event store implementation was successfully used/tested with MySql database, MongoDB database as well as with mix of the two: one database served as an event store, where second was storing projections.

Event store required structure (however different column types allowed) can be found here.

License

Package is released under the MIT License (MIT). Please, check LICENSE for more details.

Example usage

For example use of event store as well as project manager, check example/ directory.

Additionally, package provides artisan command for rebuilding all projections:

php artisan projections:rebuild

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固