reizucodes/laravel-domain-toolkit
Composer 安装命令:
composer require reizucodes/laravel-domain-toolkit
包简介
Laravel toolkit for layered architecture with repositories, services, DTOs, and domain scaffolding.
关键字:
README 文档
README
A Laravel toolkit that scaffolds a layered architecture using repositories, services, DTOs, and domain-oriented generators.
It helps enforce separation of concerns and promotes scalable, testable application design.
Requirements
- PHP 8.1 or higher
- Laravel 9, 10, 11, 12 and 13
Compatibility
This package supports:
- Laravel 9.x
- Laravel 10.x
- Laravel 11.x
- Laravel 12.x
- Laravel 13.x (Experimental)
Supporting Links
Resources related to repository patterns, service layers, and domain-oriented design.
Architecture & Domain Design
- https://dev.to/blamsa0mine/structuring-a-laravel-project-with-the-repository-pattern-and-services-11pm
- https://laravel-news.com/using-dtos-to-keep-context
- https://domainlanguage.com/ddd/reference/
Laravel Foundations
- https://laravel.com/docs/container
- https://laravel.com/docs/providers
- https://laravel.com/docs/artisan
Installation
Step 1: Install via Composer
composer require reizucodes/laravel-domain-toolkit
Step 2: Register the Service Provider (If Needed)
Laravel supports package auto-discovery, so this step is usually unnecessary.
If auto-discovery is disabled, manually register the service provider:
Laravel 10 and Below
Add to config/app.php:
'providers' => [ BlaiseBueno\LaravelDomainToolkit\DomainToolkitServiceProvider::class, ],
Laravel 11 and Above
Add to bootstrap/providers.php:
return [ BlaiseBueno\LaravelDomainToolkit\DomainToolkitServiceProvider::class, ];
Step 3: Publish Toolkit Resources
php artisan vendor:publish --tag=laravel-domain-toolkit
This will publish:
app/Repositories/BaseRepository.php
app/Repositories/Interfaces/EloquentInterface.php
app/Providers/RepositoryServiceProvider.php
stubs/domain-toolkit/
├── repository.stub
├── repository-interface.stub
├── service.stub
└── dto.stub
Publishing installs required base classes and stub templates used by the generators.
The published stubs allow you to customize how repositories, services, and DTOs are generated.
You must publish the toolkit before using the generators.
Use --force to overwrite existing files:
php artisan vendor:publish --tag=laravel-domain-toolkit --force
Repository Bindings
Repository bindings are handled through:
app/Providers/RepositoryServiceProvider.php
Laravel 11 and Above
No manual registration is required.
Laravel automatically loads providers inside the app/Providers directory.
Laravel 10 and Below
Register the provider in config/app.php:
App\Providers\RepositoryServiceProvider::class,
Smart Class Resolution
If your application defines:
- App\Support\ServiceReturn
The toolkit will automatically use your existing implementation.
Otherwise, it falls back to the package default.
Commands
All commands are registered automatically via the package.
No manual registration is required.
Service Return
The toolkit provides a ServiceReturn helper to standardize responses from the service layer.
It encapsulates:
- data
- errors
- HTTP status codes
Example:
return ServiceReturn::success($data); return ServiceReturn::clientError('Invalid input');
You can convert responses to JSON:
return $serviceReturn->toJsonResponse();
If your application defines:
App\Support\ServiceReturn
it will be used when generating services via make:service instead of the package default.
Usage
The toolkit provides generators for common architecture components.
Generate a Repository
php artisan make:repository User
Creates:
app/Repositories/UserRepository.php
app/Repositories/Interfaces/UserInterface.php
Also registers the binding in:
app/Providers/RepositoryServiceProvider.php
Generate a Service
php artisan make:service User
Creates:
app/Services/UserService.php
Generate a DTO
php artisan make:dto User
Creates:
app/DTO/UserDto.php
Nested DTOs (Recommended)
You can generate DTOs inside folders using slash notation:
php artisan make:dto Auth/User
Creates:
app/DTO/Auth/UserDto.php
Namespace:
App\DTO\Auth\UserDto
DTO Naming Rules
The generator automatically:
- Converts names to StudlyCase
- Ensures a single
Dtosuffix - Prevents duplicate suffixes
Examples:
| Input | Output |
|---|---|
User |
UserDto |
UserDto |
UserDto |
user_dto |
UserDto |
Auth/UserDTO |
Auth/UserDto |
Notes
- Nested paths (
Auth/User) are the standard way to define folders - Folder structure is automatically reflected in the namespace
- Existing files will prompt for overwrite unless
--forceis used
Generate a Full Domain Scaffold
php artisan make:domain User
Creates:
app/Models/User.php
app/Http/Controllers/UserController.php
app/Repositories/UserRepository.php
app/Repositories/Interfaces/UserInterface.php
app/Services/UserService.php
This command orchestrates the generators and sets up a complete domain layer.
Stub Customization
All generator templates are published to:
stubs/domain-toolkit/
You may modify these files to customize generated classes.
License
This package is open-source and available under the MIT license.
reizucodes/laravel-domain-toolkit 适用场景与选型建议
reizucodes/laravel-domain-toolkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「service layer」 「laravel」 「scaffolding」 「dto」 「clean architecture」 「repository pattern」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 reizucodes/laravel-domain-toolkit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 reizucodes/laravel-domain-toolkit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 reizucodes/laravel-domain-toolkit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
ADOdb is a PHP database abstraction layer library
A fast and intuitive dependency injection container.
Registry service.
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
Service auto install for Nette Framework
Structure for the Laravel Service-Repository Pattern
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 35
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-26