rva-vzw/krakboem-bundle
最新稳定版本:v0.1.2
Composer 安装命令:
composer require rva-vzw/krakboem-bundle
包简介
Symfony messenger implementation for rva-vzw/krakboem
README 文档
README
Me trying to create a Symfony bundle for rva-vzw/krakboem
(c) Johan Vervloet 2023, 2024
Licensed under AGPL v3 or later
This bundle tries to provide a Symfony implementation of the interfaces for event sourcing I created in rva-vzw/krakboem.
I use symfony messenger for the buses, and doctrine for the event store. (Which is probably not optimal. But it will do for now.) I tried to move normalization to the bundle as well, but I didn't succeed (yet?)
If you install the bundle, it will set up the service container for you. But since I didn't find out yet how to configure doctrine and messenger in a bundle, that's something that needs to be done manually.
There's little documentation for this (experimental) bundle. But you might want to take a look how the projects below use it:
- dikdikdik, my famous app to keep track of the score of the solo whist card game.
- wdebelek, a web app to play card games. We used it in Covid times.
- 1jg, another score app.
Warning!
krakboem-bundle is not compatible anymore with the new eversion of rva-vzw/krakboem I am working on right now. I'm not sure if it will be in the future.
Installation instructions
composer require rva-vzw/krakboem-bundle
Configuration
messenger
The configuration of the buses:
# config/packages/messenger.yaml
framework:
messenger:
default_bus: messenger.bus.commands
buses:
messenger.bus.events:
default_middleware: allow_no_handlers
middleware:
- 'RvaVzw\KrakBoemBundle\Messenger\EventStoreMiddleware'
messenger.bus.commands:
messenger.bus.replay:
default_middleware: allow_no_handlers
You also need to tag your listeners, so that the correct bus handles the correct messages:
# config/services.yaml:
services:
_instanceof:
RvaVzw\KrakBoem\EventSourcing\EventListener\EventListener:
tags: [{ name: messenger.message_handler, bus: messenger.bus.events }]
RvaVzw\KrakBoem\EventSourcing\Replay\Replayable:
tags: [{ name: messenger.message_handler, bus: messenger.bus.replay }]
RvaVzw\KrakBoem\Cqrs\CommandBus\CommandHandler:
tags: [{ name: messenger.message_handler, bus: messenger.bus.commands }]
doctrine
Regarding doctrine, I usually configure two entity managers: one for the event store, and one for the read model. This is the configuration I use for krakboem:
# config/packages/doctrine.yaml:
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '15'
orm:
auto_generate_proxy_classes: true
default_entity_manager: read_model
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
entity_managers:
read_model:
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
connection: default
mappings:
ReadModel:
is_bundle: false
dir: '%kernel.project_dir%/src/Infrastructure/ReadModel'
prefix: 'App\Infrastructure\ReadModel'
alias: ReadModel
event_store:
naming_strategy: doctrine.orm.naming_strategy.underscore
connection: default
mappings:
EventStore:
is_bundle: false
type: attribute
dir: '%kernel.project_dir%/vendor/rva-vzw/krakboem-bundle/src/Doctrine'
prefix: 'RvaVzw\KrakBoemBundle\Doctrine'
alias: EventStore
统计信息
- 总下载量: 192
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: AGPL-3.0-or-later
- 更新时间: 2024-01-09