承接 open-solid/domain 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

open-solid/domain

最新稳定版本:v1.0.3

Composer 安装命令:

composer require open-solid/domain

包简介

Domain events, event bus and more

README 文档

README

Installation

composer require open-solid/domain

Usage

Domain Events

Domain events are significant occurrences within a software system that reflect changes in the state of the domain. These events are used to capture and communicate changes, allowing different parts of the system to react accordingly.

For example, in an e-commerce application, a domain event might be "OrderPlaced" when a customer completes a purchase. This event can then trigger other actions such as updating inventory, sending a confirmation email, or processing payment. Domain events help to decouple systems, making them more modular and easier to maintain, as each component can independently respond to changes without being tightly integrated.

<?php

use OpenSolid\Bus\Handler\MessageHandlersLocator;
use OpenSolid\Bus\Middleware\HandlingMiddleware;
use OpenSolid\Bus\NativeLazyMessageBus;
use OpenSolid\Bus\NativeMessageBus;
use OpenSolid\DomainEvent\Bus\NativeDomainEventBus;
use OpenSolid\DomainEvent\DomainEvent;

final readonly class UserRegistered extends DomainEvent
{
}

final readonly class UserRegisteredSubscriber
{
    public function __invoke(UserRegistered $event): void
    {
        // Handle the event
    }
}

$nativeMessageBus = new NativeMessageBus([
    new HandlingMiddleware(
        new MessageHandlersLocator([
            UserRegistered::class => [new UserRegisteredSubscriber()],
        ]),
    ),
]);
$bus = new NativeDomainEventBus(new NativeLazyMessageBus($nativeMessageBus));

$bus->publish(new EntityUpdated('uuid'));

// do something in between ...

$bus->flush();

License

This software is published under the MIT License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固