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:
ArrayValueBooleanValueCoordinatesValueDateValueEmailValueEnumValueFloatValueIntegerValueObjectValuePhoneValueSlugValueStringValueURLValueUUIDValue
-
Domain Events
DomainEventbase class with metadata and primitives serialization.DomainEventMetadataandDomainEventPrimitivesDTOs.
-
Entities
Entitybase class with identity and domain event recording.
-
DAO Abstraction
DAOcontract for persistence operations with support forUnitOfWorkand 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
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-17