rabnawazak1 / laravel-ddd-generator
Artisan command to scaffold DDD domain modules in Laravel
Package info
github.com/rabnawazak1/laravel-ddd-generator
pkg:composer/rabnawazak1/laravel-ddd-generator
Requires
- php: ^8.5
- illuminate/console: ^10.0|^11.0|^12.0|^13.0
- illuminate/filesystem: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
This package is not auto-updated.
Last update: 2026-04-27 11:38:50 UTC
README
A Laravel Artisan command to scaffold Domain-Driven Design (DDD) module structure instantly — complete with Actions, Controller, Requests, Service, Repository, Model, and DTO stubs.
Why DDD?
Domain-Driven Design keeps large Laravel applications maintainable by grouping all files related to a domain feature together, rather than scattering them across app/Http/Controllers, app/Models, etc. This package gives you that structure with a single command.
Generated Structure
Running php artisan make:domain Hospital Patient produces:
app/
└── Domains/
└── Hospital/
└── Patient/
├── Actions/
│ ├── Create.php
│ ├── Update.php
│ ├── Delete.php
│ ├── ChangeStatus.php
│ └── Search.php
├── Controllers/
│ └── PatientController.php
├── Requests/
│ ├── StorePatientRequest.php
│ ├── UpdatePatientRequest.php
│ └── ChangePatientStatusRequest.php
├── Services/
│ └── PatientService.php
├── Repositories/
│ └── PatientRepository.php
├── Models/
│ └── Patient.php
└── DTO/
└── PatientData.php
Every file is generated with a namespace-correct stub and TODO markers to guide your implementation.
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.5 |
| Laravel | 10.x / 11.x / 12.x / 13.x |
Installation
Install via Composer:
composer require rabnawazak1/laravel-ddd-generator --dev
The
--devflag is recommended since this is a development scaffolding tool. The package is auto-discovered by Laravel — no manual provider registration needed.
Usage
php artisan make:domain {Domain} {Module}
Examples
# Hospital Management System php artisan make:domain Hospital Patient php artisan make:domain Hospital Doctor php artisan make:domain Hospital Appointment # E-commerce php artisan make:domain Shop Product php artisan make:domain Shop Order php artisan make:domain Shop Invoice # Multi-word inputs use StudlyCase automatically php artisan make:domain HumanResources LeaveRequest
Arguments:
| Argument | Description | Example |
|---|---|---|
domain |
The top-level domain group | Hospital, Shop, Auth |
module |
The specific module inside the domain | Patient, Product, User |
Both arguments are automatically converted to StudlyCase, so hospital and Hospital produce the same result.
What Gets Generated
| File | Purpose |
|---|---|
Actions/Create.php |
Single-responsibility action for creating a record |
Actions/Update.php |
Single-responsibility action for updating a record |
Actions/Delete.php |
Single-responsibility action for deleting a record |
Actions/ChangeStatus.php |
Action for toggling/changing status |
Actions/Search.php |
Action for search/filter logic |
Controllers/{Module}Controller.php |
HTTP controller extending Laravel's base Controller |
Requests/Store{Module}Request.php |
Form request for store validation |
Requests/Update{Module}Request.php |
Form request for update validation |
Requests/Change{Module}StatusRequest.php |
Form request for status change |
Services/{Module}Service.php |
Service layer for orchestrating actions |
Repositories/{Module}Repository.php |
Repository for database query logic |
Models/{Module}.php |
Eloquent model |
DTO/{Module}Data.php |
Data Transfer Object for passing data between layers |
All files are created only if they do not already exist, so re-running the command is safe.
Suggested Architecture
Once generated, a typical request flow looks like:
Request → Controller → Service → Action → Repository → Model
↑
DTO (carries validated data between layers)
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
Please make sure your code follows PSR-12 coding standards.
Changelog
v1.0.0
- Initial release
make:domaincommand with full DDD scaffold- Support for Laravel 10, 11, 12, 13
License
The MIT License (MIT). See the LICENSE file for details.