mnavarrocarter / ddd
此包已被弃用且不再维护。未建议替代包。
一些在DDD应用程序中所需的基本功能类。
dev-master
2018-09-26 21:13 UTC
Requires
- php: ^7.1.3
- ext-json: *
- beberlei/assert: ^3.0
Requires (Dev)
- doctrine/doctrine-bundle: ^1.9
- doctrine/orm: ^2.6
- friendsofphp/php-cs-fixer: ^2.13
- php-amqplib/php-amqplib: ^2.7
- phpunit/phpunit: ^7.3
- symfony/config: ^4.1
- symfony/dependency-injection: ^4.1
- symfony/http-kernel: ^4.1
- symfony/messenger: ^4.1
Suggests
- doctrine/orm: To be able to use Doctrine Repositories
- php-amqplib/php-amqplib: To be able to use the Rabbit MQ Producer
This package is auto-updated.
Last update: 2019-08-18 18:30:27 UTC
README
这些工具提供了一些在DDD应用程序中所需的基本功能类。这些工具包括
- 静态领域事件发布者和领域事件
- 事件存储仓库和Doctrine实现
- 静态事件发布实现
- 带有RabbitMQ实现的Event Notification服务
- 带有Doctrine实现的Collection接口(可分页)
- Messenger组件的Doctrine事务中间件
- 事件持久化实现
- 应用程序服务和事务操作接口
- 一些基本值对象
- 异常的问题详情接口
- 静态Symfony序列化器
依赖关系
- ext-json: 用于json序列化。
- Berbelei Assert: 用于值对象的验证。
一些考虑事项
使用静态事件发布者
在Symfony容器中注册Doctrine仓库
由于Doctrine仓库没有扩展来自“doctrine/doctrine-bundle”包的“ServiceEntityRepository”,因此不能自动注入到容器中。您将不得不使用旧方法注入它们,在实体管理器上调用一个工厂方法
# Also, a very good idea is to alias the Interfaces to the concrete implementations # This is for Symfony's Autowiring Feature MNC\DDD\Domain\Event\EventStore: alias: '@app.event_store' MNC\DDD\Application\Notification\PublishedMessageTracker: alias: '@app.message_tracker' app.event_store: class: MNC\DDD\Infrastructure\Domain\DoctrineEventStore factory: ["@doctrine.orm.entity_manager", getRepository] arguments: - 'MNC\DDD\Domain\Event\StoredEvent' app.message_tracker: class: MNC\DDD\Infrastructure\Application\Notification\DoctrineMessageTracker factory: ["@doctrine.orm.entity_manager", getRepository] arguments: - 'MNC\DDD\Domain\Event\PublishedMessage'
您还必须为此在Doctrine Bundle中注册映射,以便它能够工作
doctrine: orm: mappings: DDD: is_bundle: false type: xml dir: '%kernel.project_dir%/vendor/mnavarrocarter/ddd/src/Infrastructure/Persistence/Doctrine/Mapping' prefix: 'MNC\DDD' alias: DDD
Symfony配置
如果要将此包轻松地包含到项目中,该包附带一个Symfony Bundle。
doctrine: orm: mappings: MNCDDDBundle: is_bundle: true type: xml prefix: 'MNC\DDD\Domain\Event' alias: MNCDDD mnc_ddd: implementations: event_store: mnc_ddd.doctrine_event_store notification_tracker: mnc_ddd.doctrine_notification_tracker doctrine: manager: doctrine.orm.entity_manager