# php-code-generator **Repository Path**: shen_chu_peng/php-code-generator ## Basic Information - **Project Name**: php-code-generator - **Description**: 基于php的代码生成器 - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2025-08-27 - **Last Updated**: 2025-08-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # code-generator [中文文档](./README.md) ### introduce A php based code generator that quickly generates CURD methods from database tables is a method based on rendering templates ### environment php `^7.2|^8.0` ### support Currently only support laravel, webman, goravel, drogon and so on will be supported in the future, also welcome to submit templates - [x] PHP-laravel snake case - [x] PHP-laravel camel case - [x] PHP-webman snake case - [x] PHP-webman camel case - [x] Golang-goravel snake case - [x] Golang-goravel camel case - [x] PHP-hyperf snake case - [x] PHP-hyperf camel case - [ ] CPP-drogon snake case - [ ] CPP-drogon camel case ### composer ``` composer require zx/php-code-generator ``` ### About soft delete version 1,laravel, webman, etc. use Eloquent ORM frameworks, because you only need to add `use SoftDeletes` to `model` separately 2,The hump commands the conversion inside the orm,`composer require kirkbushell/eloquence` ``` Add the eloquence service provider to your config/app.php file 'providers' => [ /* * Application Service Providers... */ Eloquence\EloquenceServiceProvider::class, ], ``` example: ``` 'mysql', 'host' => '127.0.0.1', 'port' => '3306', 'dbname' => 'web', 'charset' => 'utf8', 'user' => 'root', 'pwd' => 'root' ]; MysqlOperation::setConnection($param); /* * laravel生成器,参考项目: https://github.com/zh7314/zx-laravel-cms https://gitee.com/open-php/zx-laravel-cms * $camel true => case camel,true => case snake */ Laravel::genAllTable(); Laravel::genAllRouter(); Laravel::genTable("table_name"); Laravel::genRouter("table_name"); /* * webman 生成器,配合使用项目: https://github.com/zh7314/zx-webman-cms https://gitee.com/open-php/zx-webman-cms * $camel true => case camel,true => case snake */ Webman::genAllTable(); Webman::genAllRouter(); Webman::genTable("table_name"); Webman::genRouter("table_name"); /* * goravel 生成器,配合使用项目: https://github.com/zh7314/zx-goravel-cms https://gitee.com/open-php/zx-goravel-cms * $camel true => case camel,true => case snake */ Goravel::genAllTable(); Goravel::genAllRouter(); Goravel::genTable("table_name"); Goravel::genRouter("table_name"); /* * drogon 生成器,配合使用项目: https://github.com/zh7314/zx-drogon-cms https://gitee.com/open-php/zx-drogon-cms * $camel true => case camel,true => case snake */ Drogon::genAllTable(); Drogon::genAllRouter(); Drogon::genTable("table_name"); Drogon::genRouter("table_name"); /* * laravelzx 定制化生成器 */ LaravelSoftDelZx::genAllTable(); LaravelSoftDelZx::genAllRouter(); LaravelSoftDelZx::genTable("table_name"); LaravelSoftDelZx::genRouter("table_name"); ``` 6, If you use the default template directly you may need some helper code They will be in `laravel/utils` in `tests/Tools` Add in `composer.json` ``` "autoload": { "files": [ "app/Utils/Function.php" ] } ``` 7, If you don't like to use some auxiliary code, you can change the return code to ``` return response()->json(['code' => 200, 'msg' => '成功']); ``` So standard laravel writing, code check can also be changed ``` $where['weixin_phone'] = !empty($request->weixin_phone) ? (string)htmlspecialchars(trim($request->weixin_phone), ENT_QUOTES, "UTF-8") : ''; ``` #### Custom template 1, extend `ZX\BaseGenerator` 2, Implementation of abstract methods, referring to the `XXGenerator` method to achieve their own templates, general methods are provided #### 问题反馈 QQ群:247823727 博客:https://www.cnblogs.com/zx-admin/ gitee:https://gitee.com/open-php/php-code-generator github:https://github.com/zh7314