mauretto78 / simple-event-store-manager-bundle
PHP Bundle
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Type:symfony-bundle
Requires
- mauretto78/simple-event-store-manager: ^2.0
- symfony/config: ~2.3|~3.0
- symfony/dependency-injection: ~2.3|~3.0
- symfony/framework-bundle: ^3.3
- symfony/http-kernel: ~2.3|~3.0
- symfony/yaml: ~2.3|~3.0
README
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 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.
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
- Mauro Cassani - github
License
This project is licensed under the MIT License - see the LICENSE.md file for details