A lightweight PHP library providing essential building blocks for Domain-Driven Design (DDD) applications.
- 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
- PHP 8.2 or higher
- Composer
composer require domain-engine/libraryuse 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");
}
}
}use DomainEngine\Library\Domain\DomainEvent;
class UserRegistered extends DomainEvent
{
public function __construct(
private string $userId,
private string $email
) {
}
}use DomainEngine\Library\Application\Command;
class RegisterUserCommand extends Command
{
public function __construct(
public readonly string $email,
public readonly string $password
) {}
}Contributions are welcome! Please feel free to submit a Pull Request, feedback or Idea.
This project is licensed under the MIT License - see the LICENSE file for details.