PHPackages                             lava83/laravel-ddd - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. lava83/laravel-ddd

ActiveLibrary

lava83/laravel-ddd
==================

A comprehensive toolkit providing foundational building blocks for implementing Domain-Driven Design (DDD) patterns in Laravel 12+ applications. This package offers battle-tested base classes, contracts, and infrastructure components to help you build scalable, maintainable domain-driven applications.

v0.1.4.10(1mo ago)087[1 issues](https://github.com/lava83/laravel-ddd/issues)MITPHPPHP ^8.3CI failing

Since Dec 26Pushed 1mo agoCompare

[ Source](https://github.com/lava83/laravel-ddd)[ Packagist](https://packagist.org/packages/lava83/laravel-ddd)[ Docs](https://github.com/lava83/laravel-ddd)[ GitHub Sponsors](https://github.com/Lava83)[ RSS](/packages/lava83-laravel-ddd/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (24)Versions (20)Used By (0)

DDD Foundation for Laravel
==========================

[](#ddd-foundation-for-laravel)

Important

Currently work in progress! 🚧

A comprehensive toolkit providing foundational building blocks for implementing Domain-Driven Design (DDD) patterns in Laravel 12+ applications. This package offers battle-tested base classes, contracts, and infrastructure components to help you build scalable, maintainable domain-driven applications.

Features
--------

[](#features)

- 🏗️ **Aggregate &amp; Entity Base Classes** - Ready-to-use foundation for domain entities with built-in versioning and timestamps
- 🎯 **Event Sourcing Support** - Complete domain event handling with automatic event dispatching via Laravel's event system
- 🔄 **Repository Pattern** - Abstract repository implementation with entity-model mapping
- 🗺️ **Entity-Model Mappers** - Clean separation between domain and infrastructure layers
- 🆔 **UUID Primary Keys** - Built-in UUID support for entities and models
- 🔐 **Optimistic Locking** - Automatic version tracking to prevent concurrent update conflicts
- 📦 **Value Objects** - Type-safe value object implementations (MongoObjectId, UUID, Email, Link, Json)
- 🔌 **Service Layer Pattern** - Interfaces for application and domain services
- ⚡ **Transaction Support** - Automatic transaction handling in repositories

Requirements
------------

[](#requirements)

- **PHP**: 8.3+
- **Laravel**: 12+
- **Dependencies**:
    - `illuminate/support`
    - `illuminate/database`
    - `illuminate/events`
    - `spatie/laravel-data`
    - `ramsey/uuid`

Installation
------------

[](#installation)

Install via Composer:

```
composer require lava83/ddd-foundation
```

Core Concepts
-------------

[](#core-concepts)

### Entity Hierarchy

[](#entity-hierarchy)

```
Entity (Base)
    ├── Aggregate (extends Entity + Event Handling)
    └── Child Entities (extend Entity)

```

Quick Start Guide
-----------------

[](#quick-start-guide)

### 1. Creating an Entity

[](#1-creating-an-entity)

Entities are domain objects with identity that can change over time:

```
