Download the PHP package neos/event-sourcing-symfony-bridge without Composer
On this page you can find all versions of the php package neos/event-sourcing-symfony-bridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download neos/event-sourcing-symfony-bridge
More information about neos/event-sourcing-symfony-bridge
Files in neos/event-sourcing-symfony-bridge
Package event-sourcing-symfony-bridge
Short Description Symfony bridge to integrate Event Sourcing and CQRS pattern in your Symfony framework.
License MIT
Informations about the package event-sourcing-symfony-bridge
Symfony bridge for Event Sourcing and CQRS
Library providing interfaces and implementations for event-sourced applications for Symfony Applications.
This package is the symfony adapter of Neos.EventSourcing (which was created for the Neos/Flow framework).
Demo
Check out the Symfony Demo Repository:
https://github.com/Inchie/symfony-eventsourcing-demo.git
Getting started
In your symfony application, install this package and neos/event-sourcing via composer:
Setting up a Doctrine Event Store
Since there could be multiple Event Stores simultaneously in one application, this package comes without a pre-configured "default" store. It is just a matter of a couple of lines of YAML to configure a custom store:
config/packages/neos_eventsourcing.yaml:
Set the charset in the doctrine config to utf8mb4 by adding the following lines.
config/packages/doctrine.yaml:
Add the following to bundles.php:
To make use of the newly configured Event Store one more step is required in order to finish the setup (in this case to create the corresponding database table):
Writing events
Example event: BlogWasCreated.php
Reading events
Reacting to events
In order to react upon new events you'll need an event listener:
The when*()
methods of classes implementing the EventSubscriberInterface
and ProjectorInterface
will be invoked whenever a corresponding event is committed to the Event Store.
NOTE!!! You always have to use "when*" namings, as otherwise, the EventListenerInvoker will not properly call the right methods here (see https://github.com/neos/Neos.EventSourcing/issues/282)
Replay projection
With the following command you can rebuild a projection.
Events & event listeners
The Neos EventSourcing package comes with its own events and event listeners implementation. We cannot use this implementation for several reasons in the symfony context.
To get the listeners (subscribers in symfony) for an event we call the symfony event dispatcher (in the SymfonyEventPublisher).
The listeners are handled by the InternalCatchUpEventListenerCommand. This command uses the (Neos EventSourcing) EventListenerInvoker to call the listeners method name.
The specialty about this is that the EventSourcing package uses the "when" namings. For that reason the listeners method names have to start with when prefix too (@see Reacting to events).
All configuration options in neos_eventsourcing.yml
stores
[name of event store]
eventTableName
: database table name to use as event storage (required)storage
: which storage engine to use for persisting events. A class name, by default:Neos\EventSourcing\EventStore\Storage\Doctrine\DoctrineEventStorage
eventPublisherTransport
: Class name. How the asychronity between event store and projection is implemented. By default,Neos\EventSourcing\SymfonyBridge\Transport\ConsoleCommandTransport
is used, but alsoNeos\EventSourcing\SymfonyBridge\Transport\MessengerTransport
is possible.
Internal Implementation
How is this package constructed? We try to give an overview here:
composer.json
We replace neos/flow
and flowpack/jobqueue-common
to ensure these are not installed.
All versions of event-sourcing-symfony-bridge with dependencies
symfony/serializer Version ^5.4
symfony/property-access Version ^5.4
neos/error-messages Version *
neos/utility-objecthandling Version *
ramsey/uuid Version ^3.9