Shared kernel value objects and domain abstractions for building domain-driven PHP applications.
Require the package via Composer:
composer require schorts/shared-kernelComposer will autoload classes under the namespace:
Schorts\SharedKernel\For example, classes in src/ValueObjects/ are available under:
use Schorts\SharedKernel\ValueObjects\EmailValue;-
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.
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;
}use Schorts\SharedKernel\DomainEvent\DomainEvent;
class UserRegisteredEvent extends DomainEvent {
public function getEventName(): string {
return 'user.registered';
}
}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
}
}LGPL-3.0-or-later