mauretto78/simple-event-store-manager-bundle

v2.0.2 2017-09-19 15:20 UTC

This package is not auto-updated.

Last update: 2024-04-28 00:32:32 UTC


README

Codacy Badge license Packagist

This is the official Symfony bundle for Simple EventStore Manager package.

Install Guide

Step 1: Include Simple EventStore Manager Bundle in your project with composer:

composer require mauretto78/simple-event-store-manager-bundle

Step 2: Setup your config.yml to configure your driver and connection parameters

Here is an example:

# Simple EventStore Manager
simple_event_store_manager:
    driver: 'mongo'
    api_format: 'yaml'
    parameters:
        host: 'localhost'
        username: ~
        password: ~
        database: 'eventstore_demo'
        port: '27017'
    return_type: 'array'   
    elastic:
        host: 'localhost'
        port: '9200'
  • return_type is an optional parameter; you can choose between array or object to return aggregates
  • api_format is an optional parameter; you can choose between json (default), xml or yaml
  • elastic is an optional parameter; you can send your events to a Elastic server

Please refer to Simple EventStore Manager page for more details.

Step 3: Setup your AppKernel.php by adding the Simple EventStore Manager Bundle

// ..
$bundles[] = new SimpleEventStoreManager\Bundle\SimpleEventStoreManagerBundle();

Step 4: Setup yor routing.yml

Add these lines at the bottom of your routing.yml file:

_simple_event_store_manager:
    resource: '@SimpleEventStoreManagerBundle/Resources/config/routing.yml'

Usage Guide

You can use EventsManager in your Controllers:

// ..

$manager = $this->container->get('simple_event_store_manager');
$eventManager = $manager->getEventMananger();

// store events in an aggregate
$eventManager->storeEvents(
    'name-of-your-aggregate',
    [
        ...
    ]
);

// get event streams
$eventQuery = $eventStoreManager->getEventQuery();

$stream = $eventQuery->fromAggregate('Your aggregate');
foreach ($stream as $event){
    // ..
}

Or inject it into your services and classes:

services:
     # ...

     AppBundle\Your\Service:
         arguments: ['@simple_event_store_manager']
         

Please refer to official documentation of Simple EventStore Manager for basic usage of this Library.

API support

An API endpoint is automatically exposed to /_events/{aggregate}/{page} route; it will automatically paged with 25 records per page.

When a page is complete, it will set automatically an infinite cache on it.

Support

If you found an issue or had an idea please refer to this section.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details