rezzza / domain-event
此包已被弃用,不再维护。未建议替代包。
帮助应用程序更友好地处理领域事件
v0.1
2016-03-17 10:39 UTC
Requires
- php: >=5.5.9
- psr/log: ^1.0
Requires (Dev)
- phpspec/phpspec: ^2.4
Suggests
- ext-redis: To use Redis capabilities
- doctrine/common: To use ORMRepository
- symfony/event-dispatcher: To use SymfonyEventBus
- symfony/framework-bundle: To use EventDispatcherDebugCommand
This package is not auto-updated.
Last update: 2022-02-01 12:56:47 UTC
README
帮助我们的应用程序在不首先使用EventStore的情况下变得领域事件友好。
为什么?
因为我们没有找到任何处理事件(无需EventStore)的库。即使没有EventStore,领域事件也有助于开始定义你的边界上下文。
支持的事件总线
- Symfony Event dispatcher : 同步
- Redis : 异步
示例
运行示例
php examples/redis-worker.php
php examples/quickstart.php
以全栈方式,最佳选项是跟踪你的仓库中的更改
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') ]) ) ) );
事件调度器调试
为了使用Symfony调试您自己的事件调度器,我们为您添加了一个CLI。您应该将其注册为服务,并使用--service-id
选项。