usmanzahid/laravel-custom-make
Composer 安装命令:
composer require usmanzahid/laravel-custom-make
包简介
A Laravel package to generate any kind of file using custom stubs and configuration.
README 文档
README
A Laravel package to generate custom classes using user-defined stub templates and configurable paths. You can define custom make types to use with the make command.
Installation
composer require usmanzahid/laravel-custom-make
Publishing Configuration & Stubs
After installing, publish the configuration file and default stubs using:
php artisan vendor:publish --tag=config php artisan vendor:publish --tag=stubs
This will:
- Create a
config/laravel-custom-make.phpconfig file. - Publish stub files to the root
stubs/directory.
Configuration
Open config/laravel-custom-make.php to define your custom make types. Example for services:
return [ 'service' => [ 'path' => app_path('Services'), 'stub' => base_path('stubs/service.stub'), ], ];
You can define as many types as needed. Each type must include:
- path: Where the class will be generated.
- stub: The stub template used for that type.
Usage
Run the command:
php artisan make:custom {type} {Name}
Example:
php artisan make:custom service AuthService
This will generate app/Services/AuthService.php using the corresponding stub.
Use Cases
This package is ideal for:
- Adding new custom generators like Services, DTOs, Repositories, etc.
- Generating custom class types the artisan way.
- Replacing or extending Laravel's default generators.
- Creating advanced stubs with pre-defined methods, fields, or logic.
For example, you can:
- Define a custom controller.stub with commonly used methods like index, store, etc.
- Create a model.stub with predefined $fillable fields, relationships, or traits.
- Scaffold layered structures using personalized templates.
Stub File Format
Your stub file should include placeholders like:
<?php namespace {{ namespace }}; class {{ class }} { // }
Notes
Customize stubs as you need. You may want a make type to always extend a certain class. Just import that class in the stub and then extend that class For example having a base class for a certain make type, in this case services:
// Import the base class use App\Http\Services\Service; // Add it to be extended class {{ class }} extends Service
usmanzahid/laravel-custom-make 适用场景与选型建议
usmanzahid/laravel-custom-make 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 usmanzahid/laravel-custom-make 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 usmanzahid/laravel-custom-make 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-20