broadway / event-store-mongodb
A MongoDB EventStore implementation for Broadway.
Installs: 25 486
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 7
Forks: 3
Open Issues: 2
Requires
- php: >=7.2
- ext-mongodb: *
- broadway/broadway: ^2.2.1
- mongodb/mongodb: ^1.0
Requires (Dev)
- broadway/coding-standard: ^1.0
- phpstan/phpstan: @stable
- phpunit/phpunit: ^8.0
- ramsey/uuid: ^4.0
This package is auto-updated.
Last update: 2024-11-25 21:23:22 UTC
README
Installation:
Install package via composer
$ composer require broadway/event-store-mongodb
Configuration
Register the services
parameters: mongodb_host: localhost mongodb_port: 27107 mongodb_database: default services: broadway.event_store.mongodb_client: class: MongoDB\Client arguments: ['mongodb://%mongodb_host%:%mongodb_port%'] broadway.event_store.mongodb_collection: class: MongoDB\Collection factory: ['@broadway.event_store.mongodb_client', selectCollection] arguments: ['%mongodb_database%', 'events'] broadway.event_store.mongodb: class: Broadway\EventStore\MongoDB\MongoDBEventStore arguments: ['@broadway.event_store.mongodb_collection', '@broadway.serializer.payload', '@broadway.serializer.metadata']
Create index for events collection
db.getCollection('events').createIndex({'uuid': 1, 'playhead': 1},{'unique': 1});
Testing
For testing you need a running MongoDB instance. To start a local MongoDB you can use the provided docker-compose.yml:
docker-compose up -d
To run the tests:
./vendor/bin/phpunit