定制 imran-ahmed-optilius/laravel-ddd-maker 二次开发

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

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

imran-ahmed-optilius/laravel-ddd-maker

Composer 安装命令:

composer require imran-ahmed-optilius/laravel-ddd-maker

包简介

Artisan command to scaffold Clean Architecture + DDD feature files for Laravel (Action, Request, UseCase, Service, Repository, Output DTO, Response).

README 文档

README

Latest Version on Packagist Total Downloads CI License: MIT

A single Artisan command that scaffolds a complete Clean Architecture + DDD feature in seconds — Request, Action, UseCase, Service, Repository, Output DTO, and Response — all with proper namespaces, interfaces, and PSR-12 compliant code.

Requirements

Dependency Version
PHP ^8.1
Laravel ^10.0, ^11.0, or ^12.0

Installation

composer require imran-ahmed-optilius/laravel-ddd-maker --dev

Laravel's auto-discovery will register the service provider automatically.

Usage

Interactive wizard

php artisan make:ddd

The command walks you through everything step by step:

╔═══════════════════════════════════════════════════╗
║  Laravel DDD Maker  by imran-ahmed-optilius       ║
║  Clean Architecture + Domain-Driven Design        ║
╚═══════════════════════════════════════════════════╝

  Enter the file prefix (e.g. ForHomePageTeacherGet):
  > ForHomePageTeacherGet

  ── Complexity & Naming Questions ─────────────────────────────

  Will this feature require Value Objects (VO) for IDs, status, or types? (yes/no) [no]:
  > no

  Will the Repository require a dedicated Input DTO for its arguments? (yes/no) [no]:
  > no

  Will the Service require a dedicated Input DTO for its arguments? (yes/no) [no]:
  > no

  Will the Response have a different or multiple names? (yes/no) [no]:
  > no

  Will the Output (DTO) have a different or multiple names? (yes/no) [no]:
  > no

  Will the Repository have a different or multiple names? (yes/no) [no]:
  > no

  Is there a need for a domain Entity class? (yes/no) [no]:
  > no

  Should an Eloquent Model be generated? (yes/no) [no]:
  > no

  Will this feature need a Request (Form Request) class? (yes/no) [yes]:
  > yes
  Request class name [default: ForHomePageTeacherGetRequest]:
  >

  Enter the feature folder name (e.g. HomePage or MembershipStatus/History):
  > HomePage

  ── Files to be generated ─────────────────────────────────────

    Request:
      • app/Http/Requests/Api/V1/HomePage/ForHomePageTeacherGetRequest.php
    Action:
      • app/Http/Controllers/Api/V1/HomePage/ForHomePageTeacherGetAction.php
    Use Case:
      • app/UseCases/HomePage/IForHomePageTeacherGetUseCase.php
      • app/UseCases/HomePage/ForHomePageTeacherGetUseCase.php
    Domain Service:
      • app/Domain/HomePage/Services/IForHomePageTeacherGetService.php
      • app/Infra/HomePage/Services/ForHomePageTeacherGetService.php
    Repository:
      • app/Domain/HomePage/Repositories/IForHomePageTeacherGetRepository.php
      • app/Infra/HomePage/Repositories/ForHomePageTeacherGetRepository.php
    Output DTO:
      • app/Domain/HomePage/Services/Output/ForHomePageTeacherGetOutput.php
    Response:
      • app/Http/Responses/Api/V1/HomePage/IForHomePageTeacherGetResponse.php
      • app/Http/Responses/Api/V1/HomePage/ForHomePageTeacherGetResponse.php

  Generate all files now? (yes/no) [yes]:
  > yes

  ── Generating ────────────────────────────────────────────────
  ✔ CREATED  app/Http/Requests/Api/V1/HomePage/ForHomePageTeacherGetRequest.php
  ✔ CREATED  app/Http/Controllers/Api/V1/HomePage/ForHomePageTeacherGetAction.php
  ...

  ── Add to AppServiceProvider::register() ─────────────────────
  ...

  ── Add to routes/api.php ─────────────────────────────────────
  Route::get('/for-home-page-teacher-get', \App\Http\Controllers\Api\V1\HomePage\ForHomePageTeacherGetAction::class);

  Done! All files generated successfully.

With inline options

php artisan make:ddd --prefix=ForHomePageTeacherGet --folder=HomePage

Multiple repositories, outputs, or responses

When the wizard asks "use a custom or multiple names?", answer yes and enter each name one by one. Leave the input blank to finish.

Generated File Structure

app/
├── Http/
│   ├── Requests/Api/V1/{Folder}/
│   │   └── {Prefix}Request.php               ← FormRequest (Optional)
│   ├── Controllers/Api/V1/{Folder}/
│   │   └── {Prefix}Action.php                ← Invokable controller
│   └── Responses/Api/V1/{Folder}/
│       ├── I{Response}.php                   ← Response interface
│       └── {Response}.php                    ← Response implementation
├── Models/
│   ├── {Model}.php                           ← Eloquent Model (Optional)
│   └── Entities/
│       └── {Entity}.php                      ← Domain Entity (Optional)
├── UseCases/{Folder}/
│   ├── I{Prefix}UseCase.php                  ← UseCase interface
│   └── {Prefix}UseCase.php                   ← UseCase implementation
├── Domain/{Folder}/
│   ├── Vo/
│   │   └── {Vo}.php                          ← Value Object (Optional)
│   ├── Services/
│   │   ├── I{Prefix}Service.php              ← Domain Service interface
│   │   ├── Input/
│   │   │   └── {Prefix}ServInput.php         ← Service Input DTO (Optional)
│   │   └── Output/
│   │       └── {Output}.php                  ← Output DTO
│   └── Repositories/
│       ├── I{Repo}.php                       ← Repository interface
│       └── Input/
│           └── {Repo}Input.php               ← Repository Input DTO (Optional)
└── Infra/{Folder}/
    ├── Services/
    │   └── {Prefix}Service.php               ← Service implementation
    └── Repositories/
        └── {Repo}.php                        ← Eloquent repository

After Generation

1. Register bindings in AppServiceProvider

The command prints the exact snippet. Add it to the register() method:

use App\UseCases\HomePage\IForHomePageTeacherGetUseCase;
use App\UseCases\HomePage\ForHomePageTeacherGetUseCase;
// ... other imports

public function register(): void
{
    // Use Cases
    $this->app->bind(IForHomePageTeacherGetUseCase::class, ForHomePageTeacherGetUseCase::class);

    // Domain Services
    $this->app->bind(IForHomePageTeacherGetService::class, ForHomePageTeacherGetService::class);

    // Repositories
    $this->app->bind(IForHomePageTeacherGetRepository::class, ForHomePageTeacherGetRepository::class);

    // Responses
    $this->app->bind(IForHomePageTeacherGetResponse::class, ForHomePageTeacherGetResponse::class);
}

2. Register the route in routes/api.php

The command prints this too:

Route::get('/for-home-page-teacher-get', \App\Http\Controllers\Api\V1\HomePage\ForHomePageTeacherGetAction::class);

3. Fill in the TODO placeholders

Each generated file has clearly marked TODO comments:

  • rules() in the Request class — add your validation rules
  • Constructor properties + getters in the Output DTO
  • toArrayResponse() mapping in the Response class
  • Eloquent queries in the Repository implementation
  • Field mapping in the Service implementation

Customising Stubs

All stubs live in vendor/imran-ahmed-optilius/laravel-ddd-maker/src/Stubs/*.stub.

If you want to permanently customise them for your project, copy the src/Stubs folder into your project and update StubRenderer::$stubPath to point to your copy, or publish them once support for php artisan vendor:publish is added in a future version.

Running Tests

composer install
vendor/bin/phpunit

Changelog

See CHANGELOG.md.

License

MIT — see LICENSE.

imran-ahmed-optilius/laravel-ddd-maker 适用场景与选型建议

imran-ahmed-optilius/laravel-ddd-maker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「generator」 「boilerplate」 「scaffold」 「laravel」 「ddd」 「artisan」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 imran-ahmed-optilius/laravel-ddd-maker 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-12