ldaidone / laravel-ddd-commands
A lightweight toolkit that adds Domain-Driven Design scaffolding to any Laravel project. Generate domains, use cases, entities, value objects, repositories, and more with expressive artisan commands โ keeping your architecture clean and consistent with zero friction.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/ldaidone/laravel-ddd-commands
Requires
- php: >=8.1
- illuminate/console: ^10.0 || ^11.0 || ^12.0
- illuminate/support: ^10.0 || ^11.0 || ^12.0
Requires (Dev)
- laravel/pint: ^1.0 || ^2.0
- orchestra/testbench: ^9.0 || ^10.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0 || ^11.0
This package is auto-updated.
Last update: 2025-11-23 13:14:17 UTC
README
A lightweight toolkit that adds Domain-Driven Design scaffolding to any Laravel project.
Generate domains, use cases, entities, value objects, repositories, events, aggregates, DTOs, actions, and more with expressive artisan commands using the pattern <domain_name>/<element_name> โ keeping your architecture clean and consistent with zero friction.
โจ Features
- ๐ง Generate domains, use cases, entities, value objects, repositories, events, aggregates, DTOs, commands, queries, and actions
- โก Works in any Laravel project (no special folder structure required)
- ๐งฉ Consistent naming convention:
<domain_name>/<element_name>for all generators - ๐งฉ Fully configurable namespace & path mappings
- ๐ Ships with clean, extensible stub templates for all generators
- ๐งฑ Encourages modular, maintainable DDD architecture
- ๐ Zero learning curve โ powered entirely through artisan commands
๐ฆ Installation
composer require ldidone/laravel-ddd-commands
Laravel auto-discovers the service provider โ no configuration needed.
โถ๏ธ Usage
Important: All generators follow the format
<domain_name>/<element_name>, wheredomain_namecorresponds to a domain folder andelement_nameis the name of the element you want to create.
Create a domain
php artisan ddd:create-domain Billing
Create a use case
php artisan ddd:create-use-case Billing/RegisterUser
Create an entity
php artisan ddd:create-entity Billing/User
Create a value object
php artisan ddd:create-value-object Billing/Email
Create a repository
php artisan ddd:create-repository Billing/UserRepository
Create a domain event
php artisan ddd:create-event Billing/UserRegistered
Create an aggregate
php artisan ddd:create-aggregate Billing/Order
Create a DTO (Data Transfer Object)
php artisan ddd:create-dto Billing/UserDto
Create a command
php artisan ddd:create-command Billing/RegisterUser
Create a query
php artisan ddd:create-query Billing/GetUserById
Create an action
php artisan ddd:create-action Billing/SendEmail
List available commands
php artisan list ddd
๐ Default Folder Structure
The generator uses a clean, Laravel-friendly structure (fully customizable):
app/
โโโ Domain/
โโโ Billing/
โโโ Entities/
โโโ ValueObjects/
โโโ DataTransferObjects/
โโโ UseCases/
โโโ Actions/
โโโ Repositories/
โโโ Events/
You can override this via config/ddd.php (published automatically when needed).
โ๏ธ Configuration
To publish configuration + stubs:
php artisan vendor:publish --tag=ddd-commands-config php artisan vendor:publish --tag=ddd-commands-stubs
This allows you to customize:
- folder paths
- namespace prefixes
- stub templates
- repository patterns
- additional generators
๐งช Running Tests
composer test
If you're using Pest or PHPUnit, the workflow will handle it automatically.
๐ Test Coverage
If using Codecov:
vendor/bin/phpunit --coverage-clover=coverage.xml
GitHub Actions will upload coverage after each test run.
๐ Roadmap
- Aggregate root generator
- Domain event generator
- DTO generator
- Action generator
- CQRS mode (command/query separation)
- Repository implementation generator (Eloquent/Query Builder)
Support
If this saves you time or helps your project, consider starring โญ and consider buying me a coffee! โ๏ธ โ it keeps the ideas flowing!
๐ค Contributing
Pull requests are welcome. Please open an issue first for major changes. Make sure to update tests as needed.
๐ License
Released under the Apache 2.0 license.