Laravel Broadway is an adapter for the Broadway package.
It binds all needed interfaces for Broadway.
For reference, I've built a demo laravel application that uses this package and some event sourcing techniques.
composer require nwidart/laravel-broadway=~0.1
To finish the installation you need to add the service providers.
You have a choice here, you can either use the main Service Provider which will load the following:
- CommandBus
- EventBus
- Serializers
- EventStorage
- ElasticSearch
- Support (UuidGenerators,...)
Or choose to use only the Service providers you need. Don't know what you need ? Use the Global Service Provider provided.
'Nwidart\LaravelBroadway\LaravelBroadwayServiceProvider'
-
CommandBus
'Nwidart\LaravelBroadway\Broadway\CommandServiceProvider'
-
EventBus
'Nwidart\LaravelBroadway\Broadway\EventServiceProvider'
-
Serializers
'Nwidart\LaravelBroadway\Broadway\SerializersServiceProvider'
-
EventStorage
'Nwidart\LaravelBroadway\Broadway\EventStorageServiceProvider'
-
ElasticSearch
'Nwidart\LaravelBroadway\Broadway\ElasticSearchServiceProvider'
-
Support
'Nwidart\LaravelBroadway\Broadway\SupportServiceProvider'
php artisan config:publish nwidart/laravel-broadway
To create the event store you can call the following command:
php artisan broadway:event-store:migrate table_name
In the configuration file, you can choose which driver to use as an event store.
'event-store' => [
'table' => 'event_store',
'driver' => 'dbal'
],
To set a read model in your application you first need to set the wanted read model in the package configuration.
Once that's done you can bind a ReadModelRepository like so:
$this->app->bind('Modules\Parts\Repositories\ReadModelPartRepository', function ($app) {
$serializer = $app['Broadway\Serializer\SerializerInterface'];
return new ElasticSearchReadModelPartRepository($app['Elasticsearch'], $serializer);
});
For an In Memory read model as an example:
$this->app->bind('Modules\Parts\Repositories\ReadModelPartRepository', function ($app) {
$serializer = $app['Broadway\Serializer\SerializerInterface'];
return new InMemoryReadModelPartRepository($app['Inmemory'], $serializer);
});
See the demo laravel application and specifically the Service Provider for an working example.