定制 phpgears/aggregate 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpgears/aggregate

Composer 安装命令:

composer require phpgears/aggregate

包简介

Aggregate base

README 文档

README

PHP version Latest Version License

Build Status Style Check Code Quality Code Coverage

Total Downloads Monthly Downloads

Aggregate

Aggregate base

Installation

Composer

composer require phpgears/aggregate

Usage

Require composer autoload file

require './vendor/autoload.php';

Aggregate identity

Aggregate identities are provided by gears/identity, head over there to learn about them

Aggregate root

Aggregate roots should implement Gears\Aggregate\AggregateRoot interface. You can extend from Gears\Aggregate\AbstractAggregateRoot for simplicity

use Gears\Aggregate\AbstractAggregateRoot;
use Gears\Identity\Identity;

class CustomAggregate extends AbstractAggregateRoot
{
    public static function instantiate(Identity $identity): self
    {
        return new self($identity);
    }
}

Mind that AbstractAggregateRoot constructor is protected forcing you to create static named constructors methods

Entities

Entities can implement Gears\Aggregate\Entity interface. You can extend from Gears\Aggregate\AbstractEntity for simplicity

Events

Aggregate roots can record gears/event as operations are performed

use Gears\Aggregate\AbstractAggregateRoot;
use Gears\Identity\Identity;

class CustomAggregate extends AbstractAggregateRoot
{
    public static function instantiate(Identity $identity): self
    {
        return new self($identity);
    }

    public function doSomething(): void
    {
        // do something

        $this->recordEvent(new SomethingHappened());
    }
}

These events could be collected afterwards and sent to an event bus such as gears/event

$customAggregate = CustomAggregate::instantiate(
    UuidIdentity::fromString('4c4316cb-b48b-44fb-a034-90d789966bac')
);
$customAggregate->doSomething();

foreach ($customAggregate->collectRecordedEvents() as $event) {
    /** @var \Gears\Event\EventBus $eventBus */
    $eventBus->dispatch($event);
}

Contributing

Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.

See file CONTRIBUTING.md

License

See file LICENSE included with the source code for a copy of the license terms.

统计信息

  • 总下载量: 242
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固