定制 schorts/shared-kernel 二次开发

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

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

schorts/shared-kernel

Composer 安装命令:

composer require schorts/shared-kernel

包简介

Shared kernel value objects and domain abstractions

README 文档

README

Shared kernel value objects and domain abstractions for building domain-driven PHP applications.

📦 Installation

Require the package via Composer:

composer require schorts/shared-kernel

Composer will autoload classes under the namespace:

Schorts\SharedKernel\

For example, classes in src/ValueObjects/ are available under:

use Schorts\SharedKernel\ValueObjects\EmailValue;

🧩 Features

  • Value Objects

    Immutable primitives with validation and equality logic:

    • ArrayValue
    • BooleanValue
    • CoordinatesValue
    • DateValue
    • EmailValue
    • EnumValue
    • FloatValue
    • IntegerValue
    • ObjectValue
    • PhoneValue
    • SlugValue
    • StringValue
    • URLValue
    • UUIDValue
  • Domain Events

    • DomainEvent base class with metadata and primitives serialization.
    • DomainEventMetadata and DomainEventPrimitives DTOs.
  • Entities

    • Entity base class with identity and domain event recording.
  • DAO Abstraction

    • DAO contract for persistence operations with support for UnitOfWork and delete modes.

🚀 Usage

Example: Creating a Value Object

use Schorts\SharedKernel\ValueObjects\EmailValue;

class UserEmail extends EmailValue {
  public function getAttributeName(): string {
    return 'user_email';
  }
}

$email = new UserEmail('test@example.com');

if ($email->isValid()) {
  echo "Valid email: " . $email;
}

Example: Defining a Domain Event

use Schorts\SharedKernel\DomainEvent\DomainEvent;

class UserRegisteredEvent extends DomainEvent {
  public function getEventName(): string {
    return 'user.registered';
  }
}

Example: Entity with Domain Events

use Schorts\SharedKernel\Entity\Entity;
use Schorts\SharedKernel\ValueObjects\ValueObject;
use Schorts\SharedKernel\Model\Model;

class UserEntity extends Entity {
  public function toPrimitives(): Model {
    // return DTO representation
  }
}

📜 License

LGPL-3.0-or-later

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固