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: 17

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ldaidone/laravel-ddd-commands

v0.1.1 2025-11-25 21:38 UTC

This package is auto-updated.

Last update: 2025-12-25 21:57:10 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

๐Ÿ— About the Folder Structure (Important)

As of v0.1.1, the package no longer uses configuration files or dynamic paths.

This is an intentional design choice.

Why?

Because dynamic paths introduce architectural drift. For DDD, structure must be stable, predictable, enforceable, and the same across dev machines, CI runners, and Testbench environments.

The generators now follow a single, consistent convention:

app/
โ””โ”€โ”€ Domain/
    โ””โ”€โ”€ Billing/
        โ”œโ”€โ”€ Entities/
        โ”œโ”€โ”€ ValueObjects/
        โ”œโ”€โ”€ DataTransferObjects/
        โ”œโ”€โ”€ UseCases/
        โ”œโ”€โ”€ Actions/
        โ”œโ”€โ”€ Repositories/
        โ””โ”€โ”€ Events/

This improves:

  • maintainability
  • discovery
  • onboarding
  • large-scale refactors
  • automated testing consistency

No config required. No hidden layer. No dynamic directories.

๐Ÿ“ฆ 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

๐Ÿงช 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.

๐Ÿ“š Changelog

See CHANGELOG.md

๐Ÿ“„ License

Released under the Apache 2.0 license.