PHPackages                             shahmy/laravel-ddd-toolkit - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. shahmy/laravel-ddd-toolkit

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shahmy/laravel-ddd-toolkit
==========================

Laravel Domain-Driven Design toolkit — Artisan commands for enterprise DDD architecture generation

v1.0.3(2mo ago)013MITPHPPHP ^8.1

Since May 24Pushed 2mo agoCompare

[ Source](https://github.com/shahmy/laravel-ddd-toolkit)[ Packagist](https://packagist.org/packages/shahmy/laravel-ddd-toolkit)[ RSS](/packages/shahmy-laravel-ddd-toolkit/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (7)Versions (5)Used By (0)

laravel-ddd-toolkit
===================

[](#laravel-ddd-toolkit)

**Artisan commands for enterprise Laravel Domain-Driven Design — scaffold complete bounded contexts in seconds.**

[![Packagist Version](https://camo.githubusercontent.com/fef5c750d01838c0bc888d4ab7e34c8d53560ed7701393aa91747cd944e31771/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736861686d792f6c61726176656c2d6464642d746f6f6c6b69743f636f6c6f723d463238443141)](https://packagist.org/packages/shahmy/laravel-ddd-toolkit)[![PHP](https://camo.githubusercontent.com/3a73e2280ec14e7ba71344d0c7bcdf21c2f95f4bd8ee037a42fdbd89da744e65/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d373737424234)](https://packagist.org/packages/shahmy/laravel-ddd-toolkit)[![Laravel](https://camo.githubusercontent.com/d18a9b9d389f5dcbeab9f8555024945fdd470786c7c62fb0ebbc6589441edd19/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302532302537432532303131253230253743253230313225323025374325323031332d464632443230)](https://packagist.org/packages/shahmy/laravel-ddd-toolkit)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Tests](https://github.com/shahmy/laravel-ddd-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/shahmy/laravel-ddd-toolkit/actions)

---

Overview
--------

[](#overview)

`laravel-ddd-toolkit` is a Composer package that brings a full suite of `ddd:*` Artisan commands to any Laravel application. It generates the complete DDD layer structure — Application, Domain, Infrastructure, Presentation, and Tests — along with typed PHP 8.3+ class stubs for every common DDD building block.

Works standalone from the command line. Pairs seamlessly with the [Laravel DDD Architect](https://marketplace.visualstudio.com/items?itemName=shahmy.laravel-ddd-architect) VSCode extension.

---

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

[](#requirements)

- PHP **8.1+**
- Laravel **10**, **11**, **12**, or **13**

---

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

[](#installation)

```
composer require shahmy/laravel-ddd-toolkit --dev
```

The service provider is auto-discovered. Publish the config file:

```
php artisan vendor:publish --tag=ddd-config
```

This creates `config/ddd.php` in your project.

---

Configuration
-------------

[](#configuration)

`config/ddd.php`:

```
return [
    // Root directory for all DDD domains (relative to base_path())
    'src_directory' => env('DDD_SRC_DIR', 'src'),

    // Base PSR-4 namespace mapped to src_directory
    'base_namespace' => 'Src',

    // Name of the cross-domain shared bounded context
    'shared_domain' => 'Shared',

    // Automatically add PSR-4 entry to composer.json after domain creation
    'auto_register_namespaces' => true,

    // Automatically run composer dump-autoload after namespace registration
    'auto_dump_autoload' => true,

    // PHP testing framework for generated test stubs
    'test_framework' => env('DDD_TEST_FRAMEWORK', 'pest'), // 'pest' or 'phpunit'

    // Layer structure created for every new domain
    'layers' => [
        'Application'                            => ['Actions', 'Commands', 'DTOs', 'Events', 'Exceptions', 'Interfaces', 'Jobs', 'Listeners', 'Queries', 'Services', 'UseCases'],
        'Domain'                                 => ['Entities', 'Enums', 'Events', 'Exceptions', 'Repositories', 'Services', 'Specifications', 'Traits', 'ValueObjects'],
        'Infrastructure'                         => ['Cache', 'Factories', 'Mappers', 'Providers', 'Services'],
        'Infrastructure/Persistence'             => ['Eloquent', 'Migrations', 'Repositories', 'Seeders'],
        'Presentation/API'                       => ['Controllers', 'Middleware', 'Requests', 'Resources', 'Routes'],
        'Presentation/CLI'                       => [],
        'Presentation/WEB'                       => [],
        'Tests'                                  => ['Feature', 'Unit'],
    ],
];
```

---

Commands
--------

[](#commands)

### Project initialization

[](#project-initialization)

```
php artisan ddd:init
```

Creates the `src/` directory, scaffolds the `Shared` bounded context, and registers `Src\\` in `composer.json`.

---

### Domain scaffolding

[](#domain-scaffolding)

```
php artisan ddd:domain Merchant
php artisan ddd:domain Merchant --dry-run    # preview without creating files
php artisan ddd:domain Merchant --force      # overwrite if already exists
```

Generates the full bounded context under `src/Merchant/` with all layers and subfolders. Every empty directory receives a `.gitkeep`. A `README.md` and `module.json` are created at the domain root.

---

### Class generators

[](#class-generators)

All class generators follow the same pattern:

```
php artisan ddd:   [--force] [--dry-run]
```

CommandOutput locationGenerated class`ddd:entity``Domain/Entities/`Eloquent-backed domain entity`ddd:repository``Domain/Repositories/` + `Infrastructure/Persistence/Repositories/`Interface + Eloquent implementation`ddd:service``Domain/Services/`Domain service`ddd:dto``Application/DTOs/``readonly` class with `fromArray`, `fromRequest`, `toArray``ddd:action``Application/Actions/`Single-responsibility action`ddd:usecase``Application/UseCases/`Clean Architecture use case`ddd:event``Domain/Events/`Immutable domain event`ddd:value-object``Domain/ValueObjects/``readonly` value object with invariant validation`ddd:enum``Domain/Enums/`Backed PHP 8.1+ enum`ddd:policy``Domain/`Laravel policy`ddd:resource``Presentation/API/Resources/`API resource`ddd:request``Presentation/API/Requests/`Form request`ddd:test``Tests/Feature/` or `Tests/Unit/`Pest or PHPUnit test**Examples:**

```
php artisan ddd:entity Merchant Product
php artisan ddd:repository Merchant ProductRepository
php artisan ddd:service Merchant PricingService
php artisan ddd:dto Merchant CreateProductDTO
php artisan ddd:action Merchant CreateProductAction
php artisan ddd:usecase Merchant CreateProductUseCase
php artisan ddd:event Merchant ProductCreated
php artisan ddd:value-object Merchant Money
php artisan ddd:enum Merchant ProductStatus
php artisan ddd:policy Merchant OrderPolicy
php artisan ddd:resource Merchant ProductResource
php artisan ddd:request Merchant StoreProductRequest
php artisan ddd:test Merchant ProductTest --unit
```

---

Generated Domain Structure
--------------------------

[](#generated-domain-structure)

```
src/Merchant/
├── Application/
│   ├── Actions/
│   ├── Commands/
│   ├── DTOs/
│   ├── Events/
│   ├── Exceptions/
│   ├── Interfaces/
│   ├── Jobs/
│   ├── Listeners/
│   ├── Queries/
│   ├── Services/
│   └── UseCases/
├── Domain/
│   ├── Entities/
│   ├── Enums/
│   ├── Events/
│   ├── Exceptions/
│   ├── Repositories/
│   ├── Services/
│   ├── Specifications/
│   ├── Traits/
│   └── ValueObjects/
├── Infrastructure/
│   ├── Cache/
│   ├── Factories/
│   ├── Mappers/
│   ├── Persistence/
│   │   ├── Eloquent/
│   │   ├── Migrations/
│   │   ├── Repositories/
│   │   └── Seeders/
│   ├── Providers/
│   └── Services/
├── Presentation/
│   ├── API/
│   │   ├── Controllers/
│   │   ├── Middleware/
│   │   ├── Requests/
│   │   ├── Resources/
│   │   └── Routes/
│   ├── CLI/
│   └── WEB/
├── Tests/
│   ├── Feature/
│   └── Unit/
├── README.md
└── module.json

```

---

Customising Stubs
-----------------

[](#customising-stubs)

Publish the built-in stubs to your project:

```
php artisan vendor:publish --tag=ddd-stubs
```

Stubs are copied to `stubs/ddd/` in your project root. Edit them freely. The toolkit will use your versions automatically — published stubs always take precedence over the package defaults.

Stub placeholders use `{{ PLACEHOLDER }}` syntax (case-insensitive):

PlaceholderValue`{{ NAMESPACE }}`Full PSR-4 namespace for the class`{{ CLASS }}`Class name`{{ DOMAIN }}`Domain name---

Package Architecture
--------------------

[](#package-architecture)

```
src/
├── Commands/           # 15 Artisan commands (DddDomainCommand, DddEntityCommand, …)
├── Generators/
│   ├── DomainGenerator.php   # Atomic directory tree scaffolding
│   └── ClassGenerator.php    # Stub-based class file generation
├── Support/
│   ├── AtomicFilesystem.php  # Transactional filesystem (begin/stage/commit/rollback)
│   ├── ComposerUpdater.php   # PSR-4 namespace registration + dump-autoload
│   ├── StubEngine.php        # Stub resolution and placeholder replacement
│   └── NamespaceGenerator.php
└── DDDServiceProvider.php

```

**Atomic operations** — all file and directory creation runs inside a transaction. Any failure triggers a full rollback, leaving no partial structures on disk.

---

Testing
-------

[](#testing)

```
composer install
./vendor/bin/pest
./vendor/bin/pest --coverage    # requires Xdebug or PCOV
```

Code style is enforced by [Laravel Pint](https://laravel.com/docs/pint):

```
./vendor/bin/pint               # fix
./vendor/bin/pint --test        # check only (CI mode)
```

---

VSCode Integration
------------------

[](#vscode-integration)

This package works as a standalone CLI toolkit. If you use VSCode, the [Laravel DDD Architect](https://marketplace.visualstudio.com/items?itemName=shahmy.laravel-ddd-architect) extension detects this package and delegates all generation commands to it — giving you the same results from the Command Palette or sidebar without typing Artisan commands manually.

---

Contributing
------------

[](#contributing)

1. Fork the repository and branch from `main`.
2. Use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages.
3. Ensure `./vendor/bin/pest` passes and `./vendor/bin/pint --test` reports no violations.
4. Add a `CHANGELOG.md` entry under `[Unreleased]`.
5. Open a pull request.

---

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for release history.

---

License
-------

[](#license)

MIT © [shahmy](https://github.com/shahmy)

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance88

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

61d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc45e3416091f9d71c14857c86af542a2554ee536edb6741400810f80140eeb0?d=identicon)[amshahmy](/maintainers/amshahmy)

---

Top Contributors

[![shahmy](https://avatars.githubusercontent.com/u/3964390?v=4)](https://github.com/shahmy "shahmy (4 commits)")

---

Tags

laravelscaffoldinggeneratorartisanDomain Driven Designdddclean architecture

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/shahmy-laravel-ddd-toolkit/health.svg)

```
[![Health](https://phpackages.com/badges/shahmy-laravel-ddd-toolkit/health.svg)](https://phpackages.com/packages/shahmy-laravel-ddd-toolkit)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M246](/packages/laravel-ai)[illuminate/queue

The Illuminate Queue package.

20432.6M1.7k](/packages/illuminate-queue)[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[laravel/folio

Page based routing for Laravel.

603583.7k34](/packages/laravel-folio)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
