laravel-ddd/starter
Composer starter kit that turns a fresh Laravel 12/13 app into a Domain-Driven Design structure. Includes base Entity/ValueObject/Repository/Service classes, 12 generators, interactive installer (auth, docs, tests, sample module), API-ready routes, and optional AI context.
Strengths:
RepositoryInterface) and dependency injection, reducing tight integration with Laravel’s core.routes/domains/) and controllers are thin, delegating logic to services—ideal for REST/GraphQL APIs.AGENTS.md provides structured documentation for AI agents (e.g., GitHub Copilot, custom LLM workflows) to understand domain logic.Weaknesses:
app_path('Domains') and relies on Eloquent for persistence, which could limit portability to non-Laravel PHP apps.Entity, ValueObject).composer require and interactive CLI.| Risk Area | Mitigation Strategy |
|---|---|
| DDD Misapplication | Enforce code reviews to validate domain boundaries and avoid "anemic domain model" patterns. |
| Performance Overhead | Profile repository/service layers; consider caching (e.g., Laravel’s Cache facade) for read-heavy operations. |
| Tooling Dependencies | Lock test package (PHPUnit/Pest) early to avoid runtime conflicts. |
| AI Context Gaps | Supplement AGENTS.md with custom domain-specific documentation (e.g., DOMAIN_GLOSSARY.md). |
| Migration Complexity | Pilot the package in a non-production environment first; use feature flags for gradual adoption. |
Domain Complexity:
Team Expertise:
Persistence Strategy:
API Requirements:
CI/CD Impact:
HttpFoundation for HTTP layer if needed.composer create-project laravel/laravel my-app → composer require laravel-ddd/starter → php artisan ddd:install.Users) into the DDD structure.
php artisan ddd:make-module Users
Orders domain uses DDD; legacy Products remains in app/Http/Controllers.| Component | Compatibility Notes |
|---|---|
| Laravel 12/13 | Fully supported; no breaking changes expected. |
| PHP 8.4+ | Uses modern PHP features (e.g., readonly properties, union types). |
| Eloquent | Default persistence layer; custom repositories required for other ORMs. |
| Testing | PHPUnit/Pest integration; Pest may need minor config tweaks for newer Laravel. |
| Auth | Supports Breeze (web) and Sanctum (API); custom auth (e.g., Passport) needs manual setup. |
| AI Tools | AGENTS.md provides context but may need augmentation for custom AI workflows. |
php artisan ddd:install with selected options (auth, tests, sample module).php artisan vendor:publish --tag=ddd-config.Entity for global behavior).Users) to validate the structure.php artisan ddd:make-module Products
php artisan ddd:make-entity Product Products --migration --model
php artisan ddd:make-service ProductService Products
routes/api.php or routes/web.php:
require app_path('Domains/Products/Routes/Products.php');
./vendor/bin/pest test --filter=Products
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: ./vendor/bin/pest test --filter=Domains
Domains/Users/) make code navigation intuitive.Orders) doesn’t risk breaking unrelated domains.ddd:make-entity).ddd.php config requires manual updates for custom paths or behaviors.How can I help you explore Laravel packages today?