domain-engine / library
A framework agnostic structure providing domain concepts specifications
dev-main
2026-03-12 11:34 UTC
Requires
- php: ^8.2
This package is auto-updated.
Last update: 2026-03-12 11:37:17 UTC
README
A lightweight PHP library providing essential building blocks for Domain-Driven Design (DDD) applications.
Features
- Value Objects: Base implementation for immutable value objects
- Domain Events: Foundation for domain event handling
- Aggregate Root: Base class for aggregate roots in domain models
- Commands: Base command pattern implementation
- Process manager: in development
- Query: in development
- Read model: in development
Requirements
- PHP 8.2 or higher
- Composer
Installation
composer require domain-engine/library
Usage
Value Objects
use DomainEngine\Library\Value\StringValue; class Email extends StringValue { protected static function from(string $value): self { if (!filter_var($value, FILTER_VALIDATE_EMAIL)) { throw new \InvalidArgumentException("Invalid email address"); } } }
Domain Events
use DomainEngine\Library\Domain\DomainEvent; class UserRegistered extends DomainEvent { public function __construct( private string $userId, private string $email ) { } }
Commands
use DomainEngine\Library\Application\Command; class RegisterUserCommand extends Command { public function __construct( public readonly string $email, public readonly string $password ) {} }
Contributing
Contributions are welcome! Please feel free to submit a Pull Request, feedback or Idea.
License
This project is licensed under the MIT License - see the LICENSE file for details.