Skip to content

domain-engine/library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DomainEngine Library

License: MIT PHP Version

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.

About

framework agnostic abstractions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages