# gen **Repository Path**: zhejianganchudevelopment/gen ## Basic Information - **Project Name**: gen - **Description**: laravel自动生成代码工具 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-08-22 - **Last Updated**: 2023-08-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## laravel自动生成代码工具包 ### (一). 配置`Provider` 1. 在`config/app.php`中的`providers`数组中,增加 ```php 'providers' => [ ..., // 增加配置 Xinyu\Gen\XinyuGenProvider::class, ], ``` ### (二). 使用方法 > 1. 比如生成表名称为`test_one`的文件 #### 1. 生成controller/service/model/validator脚本 * --module 【模块层,取值admin、web】 * --name 【模型名】 * --unique 【唯一字段,多个以英文逗号分隔,如name,age】 * --search 【搜索参数】 * --except 【过滤字段,多个以英文逗号分隔,如status,zz_at】 ```shell script php artisan a \ --module=admin \ --name=test_one \ --unique=age \ --search=age \ --except=status ``` #### 2. 生成controller脚本 * --module 【模块层,取值admin、web】 * --name 【模型名】 ```shell script php artisan c \ --module=admin \ --name=test_one ``` #### 3. 生成service脚本 * --module 【模块层,取值admin、web】 * --name 【模型名】 * --search 【搜索参数】 ```shell script php artisan s \ --module=admin \ --name=test_one \ --search=age ``` #### 4. 生成validator脚本 * --name 【模型名】 * --unique 【唯一字段,多个以英文逗号分隔,如name,age】 * --except 【过滤字段,多个以英文逗号分隔,如status,zz_at】 ```shell script php artisan v \ --name=test_one \ --unique=age \ --except=status ``` #### 5. 生成model脚本 * --name 【模型名】 ```shell script php artisan m --name=test_one ``` #### 6. 生成postman接口调试参数 * --name 【模型名】 * --search 【搜索参数】 * --doc 【是否生成文档参数 1=生成 0=不生成】 > 生成的文件到`/zapidoc/postman/postman.json`中查看 ```shell script php artisan makePostman \ --name=test_one \ --search=age \ --doc=1 ``` #### 7. 生成apifox接口调试参数 * --name 【模型名】 * --search 【搜索参数】 * --doc 【是否生成文档参数 1=生成 0=不生成】 > 生成的文件到`/zapidoc/apifox/apifox.json`中查看 ```shell script php artisan makeApifox --name=test_one \ --search=age \ --doc=1 ``` #### 8. 生成路由脚本 * --name 【模型名】 * --desc 【模块描述】 ```shell script php artisan makeRoute \ --name=test_one \ --desc=测试One ``` #### 9. 删除生成的controller/service/model/validator脚本 * --module 【模块层,取值admin、web】 * --name 【模型名】 ```shell script php artisan removeAll \ --module=admin \ --name=test_one ```