PHPackages                             m4rkhenzel/laravel-ddd-starter - 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. [Framework](/categories/framework)
4. /
5. m4rkhenzel/laravel-ddd-starter

ActiveProject[Framework](/categories/framework)

m4rkhenzel/laravel-ddd-starter
==============================

Production-ready Laravel 12 DDD starter kit with CQRS, layered architecture (Domain, Application, Infrastructure, UI) and thin controllers.

00PHP

Since Nov 23Pushed 5mo agoCompare

[ Source](https://github.com/M4rkH3nz3L/LaravelDDD)[ Packagist](https://packagist.org/packages/m4rkhenzel/laravel-ddd-starter)[ RSS](/packages/m4rkhenzel-laravel-ddd-starter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

 [ ![Laravel Logo](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg) ](https://laravel.com)

 **Laravel DDD Starter Kit**
 *Enterprise-grade Domain-Driven Design foundation for Laravel*

 [![Latest Version](https://camo.githubusercontent.com/ad5908d6d63c08c2b748eb9bb878a1b2985cd4406af6ddeb1352fa648aaece37/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d34726b68656e7a656c2f6c61726176656c2d6464642d73746172746572)](https://packagist.org/packages/m4rkhenzel/laravel-ddd-starter) [![Total Downloads](https://camo.githubusercontent.com/bdb3385612a03c476e2128c76b2c4defcb2e439bfb979dc04983184563911b38/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d34726b68656e7a656c2f6c61726176656c2d6464642d73746172746572)](https://packagist.org/packages/m4rkhenzel/laravel-ddd-starter) [![DDD + CQRS](https://camo.githubusercontent.com/d812026811d43545da01f122d093b215945a9569e8a9a7b0891412c4d5a9fb64/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6172636869746563747572652d444444253230253242253230435152532d626c7565)](#) [![PHP Version](https://camo.githubusercontent.com/8b0c20237824d004f37b8c2adb4917d5f345147aa7b999000dceb4a5d64e541a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e322d373737424234)](https://php.net) [![License](https://camo.githubusercontent.com/be07a68b57a673af622198c336264f89d82bf4cd5d87bc0cb3f7b6ae47cc43ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d6c6967687467726579)](https://opensource.org/licenses/MIT)

---

About Laravel DDD Starter Kit
-----------------------------

[](#about-laravel-ddd-starter-kit)

The **Laravel DDD Starter Kit** provides a clean, scalable, enterprise-ready project structure built on **Laravel 12**, implementing **Domain-Driven Design (DDD)** and **CQRS** patterns — without modifying Laravel's core.

This starter kit is designed as if **Laravel natively supported DDD out-of-the-box**, while maintaining:

- ✅ Full compatibility with Laravel's conventions
- ✅ Eloquent ORM, Service Container, Providers, Routes, Middleware
- ✅ Zero framework hacks or overrides
- ✅ Complete Laravel ecosystem integration (Sanctum, Pest, Pint, etc.)

Perfect for teams and solo developers building **large, modular, maintainable** applications with clear separation of concerns.

---

Why DDD + CQRS?
---------------

[](#why-ddd--cqrs)

### Domain-Driven Design

[](#domain-driven-design)

- **Bounded Contexts**: Isolate business domains (User, Order, Payment, etc.)
- **Ubiquitous Language**: Code mirrors business terminology
- **Rich Domain Models**: Business logic lives in entities, not controllers
- **Strategic Design**: Clear boundaries between different parts of your application

### CQRS (Command Query Responsibility Segregation)

[](#cqrs-command-query-responsibility-segregation)

- **Commands**: Write operations (CreateUser, UpdateOrder)
- **Queries**: Read operations (GetUserById, ListOrders)
- **Handlers**: Dedicated classes for each use case
- **DTOs**: Type-safe data transfer between layers

---

Key Features
------------

[](#key-features)

### 🏗️ Clean Architecture Layers

[](#️-clean-architecture-layers)

```
┌─────────────────────────────────────┐
│         UI / HTTP Layer             │  Controllers, Routes, API
├─────────────────────────────────────┤
│       Application Layer             │  Commands, Queries, DTOs, Handlers
├─────────────────────────────────────┤
│         Domain Layer                │  Entities, Value Objects, Services
├─────────────────────────────────────┤
│     Infrastructure Layer            │  Eloquent, Repositories, External APIs
└─────────────────────────────────────┘

```

### ⚡ Built-In Artisan Generators

[](#-built-in-artisan-generators)

Create complete DDD modules from the terminal:

```
php artisan ddd:context Order        # Create bounded context
php artisan ddd:entity Order Order   # Create aggregate root
php artisan ddd:vo Order OrderId     # Create value object
php artisan ddd:use-case Order PlaceOrder  # Command + Handler + DTO
php artisan ddd:eloquent-model Order Order # Model + Repository
php artisan ddd:controller Order PlaceOrder --type=api  # Controller
```

### 📦 Modular Installation System

[](#-modular-installation-system)

Add external modules as optional features using the stub system:

```
php artisan make:cms-stubs           # Generate CMS module stubs
php artisan install:cms              # Install CMS module into your app
```

This approach keeps your application lean by only including the functionality you need.

### 🧱 Framework-Independent Domain

[](#-framework-independent-domain)

- Pure PHP domain layer
- No Laravel dependencies in business logic
- Fully testable without framework
- Easy to migrate or extract

### 🧪 Testing Ready

[](#-testing-ready)

- Pest 4 integration
- Browser testing support
- Separate unit and feature tests
- Factory pattern for test data

---

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

[](#installation)

### Create New Project

[](#create-new-project)

```
composer create-project m4rkhenzel/laravel-ddd-starter my-app
cd my-app
```

### Configure Environment

[](#configure-environment)

```
cp .env.example .env
php artisan key:generate
```

### Setup Database

[](#setup-database)

```
# Configure your database in .env
php artisan migrate
```

### Start Development Server

[](#start-development-server)

```
php artisan serve
```

Visit `http://localhost:8000` — you're ready to build!

---

Directory Structure
-------------------

[](#directory-structure)

```
my-app/
├── app/
│   ├── Domain/                      # 🎯 Pure business logic
│   │   ├── Shared/
│   │   │   ├── Contracts/           # Repository interfaces
│   │   │   ├── Exceptions/          # Domain exceptions
│   │   │   └── ValueObjects/        # Shared VOs (Money, Email, etc.)
│   │   │
│   │   └── {Context}/               # Bounded Context (User, Order, etc.)
│   │       ├── Entities/            # Aggregate roots
│   │       ├── ValueObjects/        # Context-specific VOs
│   │       ├── Repositories/        # Repository interfaces
│   │       ├── Services/            # Domain services
│   │       └── Exceptions/          # Context exceptions
│   │
│   ├── Application/                 # 🔄 Use cases (CQRS)
│   │   └── {Context}/
│   │       ├── Commands/            # Write operations
│   │       ├── Queries/             # Read operations
│   │       ├── Handlers/            # Command/Query handlers
│   │       └── DTO/                 # Data Transfer Objects
│   │
│   ├── Infrastructure/              # 🔌 External integrations
│   │   ├── Persistence/
│   │   │   └── Eloquent/{Context}/
│   │   │       ├── {Entity}Model.php            # Eloquent models
│   │   │       └── {Entity}RepositoryEloquent.php  # Implementations
│   │   └── Providers/
│   │       └── DddServiceProvider.php
│   │
│   └── Http/
│       └── Controllers/             # 🌐 Thin HTTP controllers
│           └── {Context}/
│
├── routes/
│   ├── api.php                      # API routes
│   └── web.php                      # Web routes
│
└── tests/
    ├── Feature/                     # Integration tests
    ├── Unit/                        # Unit tests
    └── Browser/                     # Browser tests (Pest 4)

```

---

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

[](#quick-start-guide)

### 1. Create Your First Bounded Context

[](#1-create-your-first-bounded-context)

```
php artisan ddd:context Product
```

This creates the complete folder structure for the `Product` context:

- `app/Domain/Product/`
- `app/Application/Product/`
- `app/Infrastructure/Persistence/Eloquent/Product/`

### 2. Define Your Aggregate Root

[](#2-define-your-aggregate-root)

```
php artisan ddd:entity Product Product
```

Edit `app/Domain/Product/Entities/Product.php`:

```
