trannguyenhan/autogencontroller

自动生成控制器代码

v1 2022-04-16 16:32 UTC

This package is auto-updated.

Last update: 2024-09-09 07:54:52 UTC


README

对于每个人和每个项目,代码结构都不同,每个人有自己的风格。本项目不会帮你创建真正优秀的控制器,但可以作为基础。你可以通过修改模板文件夹来创建自己的更好版本。

配置

通过composer安装 (packagist)

composer require trannguyenhan/autogencontroller

使用方法

使用命令生成控制器和仓库

php artisan tnhgen:controller

如果你的控制器扩展了没有控制器基类的类,或者你的仓库扩展了没有基础仓库基类的类,生成控制器时需要添加参数

php artisan tnhgen:controller --basecontroller YourController --baserepository YourRepository

如果你想为控制器分配对应的模型,请使用以下参数

php artisan tnhgen:controller --model YourModel

如果控制器在命名空间中,请添加参数

php artisan tnhgen:controller --namespace YourNamespace

当然,你可以一次性组合所有上述参数。如果你想从MySQL数据库、PostgreSQL和SQLite生成模型,请参考以下仓库 https://github.com/reliese/laravel