Domain
The pure domain layer — aggregates, identities, domain events, value objects, and collections. No infrastructure dependencies.
Domain
vortos-domain is the pure domain layer. It has no dependencies on infrastructure — no Doctrine, no Redis, no HTTP. Everything in this package is plain PHP expressing business concepts.
Dependency Direction
Infrastructure depends on domain. Domain never depends on infrastructure. DbalStore and OrmStore depend on your repository interfaces. Those interfaces do not know Doctrine exists.
What's in vortos-domain
| Component | Purpose |
|---|---|
AggregateRoot | Base class for all domain aggregates |
AggregateId | Type-safe UuidV7-based identity |
DomainEvent | Base class for domain events |
AbstractCommand | Base class for CQRS commands |
ValueObject | Base class for value objects |
Collection | Type-safe domain collections |
WriteRepositoryInterface | Contract for write-side repositories |
ReadRepositoryInterface | Contract for read-side repositories |
PageResult | Cursor-based pagination result |
DomainError | Structured, typed domain failure with error code and context |
Result<T> | Explicit success/failure container — ok(), fail(), unwrap() |
#[HttpStatus] | Declares the HTTP status a DomainError maps to |
The Aggregate Pattern
final class User extends AggregateRoot
↓
UserId extends AggregateId
↓
UserRegisteredEvent extends DomainEvent
↓
Email extends ValueObjectYour domain model is built entirely from these building blocks. Infrastructure layers (DBAL, MongoDB) implement the interfaces — your domain code never imports them.
Module Overview
Aggregates
AggregateRoot — state, versioning, domain event recording.
Identity
AggregateId — typed UuidV7 identifiers with equality and string conversion.
Domain Events
DomainEvent — immutable facts, versioning, occurredAt.
Commands
AbstractCommand and CommandInterface — intent, idempotency keys.
Queries
QueryInterface — marker interface for read-side questions.
Value Objects
ValueObject — equality by value, immutability, toString.
Collections
Collection — type-safe, ordered, filterable.
Errors & Result
DomainError and Result — typed failures with stable error codes, context, and automatic HTTP mapping.