rezzza/domain-event

This package is abandoned and no longer maintained. No replacement package was suggested.

Help apps to be more domain event friendly

v0.1 2016-03-17 10:39 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:56:47 UTC


README

Library to help our apps to be domain event friendly without using EventStore at first.

Build Status

Why ?

Because we did not find any library that deal with events in an asynchronous way without EventStore. And domain events are helpful even without EventStore, to start defining boundaries between your bounded contexts.

Supported event buses

  • Symfony Event dispatcher : sync
  • Redis : async

Example

See detailled quickstart

To run example

php examples/redis-worker.php
php examples/quickstart.php

In a fullstack way the best option is to track change in your repository

class ORMBookingRepository extends ORMAggregateRootRepository implements BookingRepository
{
    public function find($bookingId)
    {
        $this->getInternalRepository->find($bookingId)
    }

    public function save(Booking $booking)
    {
        $this->getManager()->persist($booking);
        $this->getManager()->flush();
        $this->track($booking);
    }
}

$repository = new ORMBookingRepository(
    new ManagerRegistry,
    'My\FQCN\Booking',
    new ChangeTracker(
        new LoggerEventBus(
            $logger,
            new CompositeEventBus([
                new SymfonyEventBus($eventDispatcher),
                new RedisEventBus($redis, 'booking')
            ])
        )
    )
);

EventDispatcher debug

To debug your own event dispatcher with Symfony, we add a CLI for you. You should register it as a service and use the --service-id option.