This is the official Symfony bundle for Simple EventStore Manager package.
composer require mauretto78/simple-event-store-manager-bundle
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 aggregatesapi_format
is an optional parameter; you can choose betweenjson
(default),xml
oryaml
elastic
is an optional parameter; you can send your events to a Elastic server
Please refer to Simple EventStore Manager page for more details.
// ..
$bundles[] = new SimpleEventStoreManager\Bundle\SimpleEventStoreManagerBundle();
Add these lines at the bottom of your routing.yml
file:
_simple_event_store_manager:
resource: '@SimpleEventStoreManagerBundle/Resources/config/routing.yml'
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.
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.
If you found an issue or had an idea please refer to this section.
- Mauro Cassani - github
This project is licensed under the MIT License - see the LICENSE.md file for details