biig/domain

该软件包已被弃用且不再维护。作者建议使用swag-industries/doctrine-domain-events软件包。

安装次数: 19,897

依赖项: 0

建议者: 0

安全: 0

星标: 16

关注者: 6

分支: 9

开放问题: 6

类型:symfony-bundle

v2.1.4 2020-08-31 22:45 UTC

README

Build Status Latest Stable Version License

该库旨在帮助您采用领域设计开发方法构建应用程序。

它与以下软件集成良好

  • Symfony >= 4.3(对于 >=3.3 兼容性,请安装领域组件的1.5版本)
  • ApiPlatform >= 2.1
  • Doctrine >=2.5

但您可以用它来处理任何PHP项目。

这里有一些幻灯片解释了我们如何达到这一点。

功能

领域事件

缺点

此库旨在允许您将Doctrine模型用作领域模型。这有一些代价:您不能再手动实例化领域模型。这意味着您需要一个工厂来处理您领域模型的所有使用。

此组件为Symfony序列化和Doctrine提供实现。对于您的特定需求,您应该使用类(如果使用包,则使用服务)Biig\Component\Domain\Model\Instantiator\Instantiator

安装

composer require biig/domain

基本用法

class YourModel extends DomainModel
{
    public const CREATION = 'creation';
    public function __construct()
    {
        $this->dispatch(new DomainEvent($this), self::CREATION);
    }
}
class DomainRule implements DomainRuleInterface
{
    public function on()
    {
        return YourModel::CREATION;
    }
    
    public function execute(DomainEvent $event)
    {
        // Do Something on your model creation
    }
}

由于您的模型需要一个调度器,因此每次创建新的模型实例时都需要调用setDispatcher()方法。为了避免手动执行此操作,您可以使用库提供的Instantiator

它不使用构造函数来添加调度器,因为在PHP中可以不使用构造函数创建对象。例如,这是Doctrine所做的。

Symfony集成

使用包

<?php
// config/bundles.php

return [
    // ...
    Biig\Component\Domain\Integration\Symfony\DomainBundle::class => ['all' => true],
];

了解有关Symfony集成的更多信息

版本

版本 状态 文档 Symfony版本 PHP版本
1.x 维护 v1 '>= 3.3 && <5' '>= 7.1'
2.x 最新 v2 '>= 4.3' '>= 7.1'