2017 © Pedro Peláez
 

project laravel-event-sourcing

Laravel bindings for DeSmart Event Sourcing package

image

desmart/laravel-event-sourcing

Laravel bindings for DeSmart Event Sourcing package

  • Wednesday, May 25, 2016
  • by DeSmart
  • Repository
  • 8 Watchers
  • 6 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel Event Sourcing

Simple Laravel implementation of event sourcing mechanism., (*1)

Latest version Build Status Software License, (*2)

Be advised: this package is work in progress and some breaking changes may appear on the way., (*3)

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

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., (*5)

Installation

To install the package via Composer, simply run the following command:, (*6)

composer require desmart/laravel-event-sourcing

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

'providers' => [
    // ...

    DeSmart\EventSourcing\Laravel\EventStore\ServiceProvider::class,
]

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

'providers' => [
    // ...

    DeSmart\EventSourcing\Laravel\Projections\ServiceProvider::class,
]

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

php artisan vendor:publish

Configuration

Package adds two configuration files: event-store.php and read-model.php., (*10)

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., (*11)

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., (*12)

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., (*13)

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

License

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

Example usage

For example use of event store as well as project manager, check example/ directory., (*16)

Additionally, package provides artisan command for rebuilding all projections:, (*17)

php artisan projections:rebuild

The Versions

25/05 2016

dev-master

9999999-dev

Laravel bindings for DeSmart Event Sourcing package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Radoslaw Mejer
by Michal Golon

laravel event sourcing

25/05 2016

1.0.0

1.0.0.0

Laravel bindings for DeSmart Event Sourcing package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Radoslaw Mejer
by Michal Golon

laravel event sourcing