定制 hitech/ddd-modular-toolkit 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hitech/ddd-modular-toolkit

Composer 安装命令:

composer require hitech/ddd-modular-toolkit

包简介

A Laravel DDD Modular Toolkit for feature-based architecture.

README 文档

README

This package provides custom toolkit to help you generate files based on Domain-Driven Design (DDD) architecture.

📦 Installation

To install the package, run the following command in your Laravel project:

composer require hitech/ddd-modular-toolkit

Publish Configuration

# Publish all files
php artisan vendor:publish --provider="Hitech\DddModularToolkit\Providers\DddModularToolkitServiceProvider"

# Or publish separately
php artisan vendor:publish --tag=ddd-config

⚙️ Configuration Options

The ddd.php configuration file allows you to customize various aspects of the DDD Modular Toolkit. Below is a summary of the available options:

Option Description Default Value
blade.is_active Enables or disables Blade templating for modules. true
blade.path Defines the custom path for Blade views within modules. Blades
react.is_active Enables or disables React templating for modules (coming soon). true
react.path Defines the custom path for React views within modules. Views
middleware.auth Applies authentication middleware to module routes. false
middleware.api Applies API middleware to module routes. false

📁 Module Folder Structure (DDD Style)

The php artisan make:modulefiles {ModuleName} command will generate a modular structure based on Domain-Driven Design (DDD) principles. Here's how the generated folder structure looks:

app/
└── Modules/
    └── {ModuleName}/
        ├── Application/
        │   ├── Data/               # Laravel Data classes for validation/transformation
        │   ├── DTO/                # Data Transfer Objects (immutable value objects)
        │   └── Services/           # Business logic layer
        ├── Domain/
        │   └── Contracts/          # Interfaces for repositories or domain services
        │   └── Entities/           # Domain entities (business objects)
        │   └── Constants/          # Domain constants
        │   └── Enums/              # Domain enums
        ├── Infrastructure/
        │   ├── Database/
        │   │   ├── Migrations/     # Module-specific database migrations
        │   │   ├── Models/         # Eloquent models
        │   │   └── Seeders/        # Seeders for initial data
        │   └── Repositories/       # Repository implementations
        └── Interface/
            ├── Controllers/        # HTTP controllers (extends base Laravel Controller)
            ├── Requests/           # Form Request classes with validation + toDTO()
            ├── Resources/          # API resource formatters
            └── Routes/             # Module-specific route definitions
            └── Views/              # Module-specific react files
            └── Blades/             # Module-specific blade files

Each folder serves a clear role in enforcing separation of concerns, maintainability, and scalability across your Laravel application.

1. Generate Module Files

php artisan make:module {name}:{submodule} [options]

Description: Generate DDD-style modular files in the Modules/{name} directory.

Options:

  • --A|--all : Generate all components (default)
  • --D|--data : Generate data-related files (should install laravel-data)
  • --Y|--dto : Generate DTO (Data Transfer Object)
  • --M|--migration : Generate migration file
  • --O|--model : Generate model
  • --R|--repository : Generate repository
  • --S|--service : Generate service
  • --C|--controller : Generate controller
  • --Q|--request : Generate request
  • --E|--resource : Generate API resource
  • --T|--route : Generate route file
  • --X|--seeder : Generate database seeder

Usage examples:

# Generate all components for Product module
php artisan make:module Product --all

# Generate all components for Category submodule inside Product module
php artisan make:module Product:Category --all

# Generate only controller and service for Order module
php artisan make:module Order --controller --service

# Generate only controller and service for Cart submodule inside Order module
php artisan make:module Order:Cart --controller --service

# Generate repository and model for User module
php artisan make:module User -R -O

# Generate repository and model for Role submodule inside User module
php artisan make:module User:Role -R -O

2. Generate Modify Migration

php artisan modify:migration {module} {table} [options]

Description: Create a new migration file for modifying an existing table within a specific module.

Options:

  • --add-column= or --ac= : Add new column
  • --rename-column= or --rc= : Rename existing column
  • --drop-column= or --dc= : Drop column
  • --modify-column= or --mc= : Modify existing column

Usage examples:

# Add 'status' column to 'contracts' table in Contract module
php artisan modify:migration Contract contracts --ac=status:string

# Rename 'name' column to 'full_name' in users table
php artisan modify:migration User users --rc=name:full_name

# Drop 'temp_field' column from products table
php artisan modify:migration Product products --dc=temp_field

# Combine operations: add 'notes' column and drop 'old_field' column
php artisan modify:migration Order orders --ac=notes:text --dc=old_field

📋 Requirements

  • PHP ^8.1
  • Laravel ^12.19
  • Illuminate Support ^12.19
  • Illuminate Console ^12.19
  • Illuminate Database ^12.19

🤝 Contributing

Contributions are highly welcome! Please:

  1. Fork this repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License.

👨‍💻 Author

dhank77

🙏 Acknowledgments

  • Laravel Community
  • All contributors who have helped

Made with ❤️ for Laravel Community

⭐ Star this repo | 🐛 Report Bug | 💡 Request Feature

hitech/ddd-modular-toolkit 适用场景与选型建议

hitech/ddd-modular-toolkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.14k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 06 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 hitech/ddd-modular-toolkit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hitech/ddd-modular-toolkit 我们能提供哪些服务?
定制开发 / 二次开发

基于 hitech/ddd-modular-toolkit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.14k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-19