ldaidone/laravel-ddd-commands 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ldaidone/laravel-ddd-commands

最新稳定版本:v0.1.1

Composer 安装命令:

composer require 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.

README 文档

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.

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2025-11-23