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

v0.1.0 2025-11-23 12:55 UTC

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.

License Tests Coverage Packagist Downloads

"Buy Me A Coffee"

โœจ 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>, where domain_name corresponds to a domain folder and element_name is 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.