Download the PHP package net-code/laravel-domain without Composer
On this page you can find all versions of the php package net-code/laravel-domain. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download net-code/laravel-domain
More information about net-code/laravel-domain
Files in net-code/laravel-domain
Package laravel-domain
Short Description DDD tactical building blocks (aggregate root, value objects, domain events, typed UUID identifiers, business-rule specification) with optional Laravel integration.
License MIT
Informations about the package laravel-domain
net-code/laravel-domain
DDD tactical building blocks — the reusable kernel that concrete bounded contexts build on.
The core (NetCode\Domain\*) is pure PHP 8.5+ (only ramsey/uuid); a thin, optional
Laravel integration layer (NetCode\Domain\Laravel\*) wires the kernel into a Laravel app
through an auto-discovered service provider.
Install
What's inside
| Class / interface | Purpose |
|---|---|
NetCode\Domain\AggregateRoot |
Base aggregate that records and releases domain events. |
NetCode\Domain\ValueObject |
Base value object with an equals() contract. |
NetCode\Domain\DomainEvent |
Marker interface for events (occurredOn()). |
NetCode\Domain\DomainEventPublisher |
Publisher seam implemented by the host application. |
NetCode\Domain\Identifier\Uuid |
Base for typed UUID identifiers (UUIDv7). |
NetCode\Domain\Rule\BusinessRule |
A single invariant that can be broken. |
NetCode\Domain\Rule\BusinessRuleCode |
Backed-enum contract for machine-readable rule codes. |
NetCode\Domain\Rule\TranslatableRuleParams |
Optional translation parameters for a rule. |
NetCode\Domain\Rule\Specification |
Checks rules and throws BusinessRuleException on the first broken one. |
NetCode\Domain\Rule\BusinessRuleException |
Carries the broken rule's code and translation params. |
NetCode\Domain\Exception\DomainException |
Base for domain-layer exceptions. |
NetCode\Domain\Exception\InvalidArgumentException |
Invalid value-object input. |
Laravel integration (NetCode\Domain\Laravel)
| Class | Purpose |
|---|---|
DomainServiceProvider |
Auto-discovered; binds DomainEventPublisher → LaravelDomainEventPublisher. |
LaravelDomainEventPublisher |
Publishes domain events through Laravel's event dispatcher. |
IdentifierCast |
Eloquent cast between a string column and a typed Identifier\Uuid. |
Usage
Typed identifier
Aggregate + domain events
Business rules via a specification
Specification::check() is a static, stateless guard — call it directly from your aggregates.
There is no instance to construct, inject, or subclass.
Laravel integration
DomainServiceProvider is auto-discovered, so DomainEventPublisher resolves to
LaravelDomainEventPublisher (domain events go through Laravel's dispatcher) with zero wiring.
Cast a model's identifier column to its typed value object:
Development
License
MIT
All versions of laravel-domain with dependencies
illuminate/contracts Version ^13.0
illuminate/database Version ^13.0
illuminate/support Version ^13.0
ramsey/uuid Version ^4.9