Skip to content

Spread the word (synchronous and/or asynchronous) !

License

Notifications You must be signed in to change notification settings

rezzza/domain-event

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Spread the word (synchronous and/or asynchronous) !

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages