modul-is / generator
从数据库表生成实体、存储库、展示器、模板、仪表、表单和网格到指定的模块
v1.0.0
2020-04-27 08:24 UTC
Requires
- nette/database: ^3
- nette/finder: ^2
- nette/neon: ^3
- nette/utils: ^3
This package is auto-updated.
Last update: 2024-08-27 18:26:47 UTC
README
简单的命令行界面,用于从MySQL表生成PHP类
安装
通过composer.json安装,不要忘记将composer处理程序添加到项目的composer.json中
"scripts":
{
"post-install-cmd": [
"ModulIS\\Generator\\ComposerHandler::copy"
],
"post-update-cmd": [
"ModulIS\\Generator\\ComposerHandler::copy"
]
}
设置
除了local.neon
之外,无需进行其他设置 - 作为数据库的源使用
如何使用
安装扩展后,在cmd中打开vendor\bin
目录(PowerShell需要在命令前使用.\
-> .\generate
)。无需注册工厂或存储库,所有操作都自动完成
generate <mysql_table> [--module=<module_name>] [--type=<type>] [--db=<database>]
generate
generate
=> 启动生成的命令
mysql_table
mysql_table
=> 将用于生成PHP类的表名
- 如果表有前缀,类也将有前缀,例如ins_insurance将生成InsInsuranceEntity等
module_name
module_name
=> 新类将被生成的模块名称,默认为AdminModule
- module_name必须使用
PascalCaseLikeThis
格式 - module_name不需要包含
Module
- 如果缺失,则自动添加
type
type
=> 决定将生成哪些文件,默认为all
- options
- all (整个模块)
- entity
- repository
- form
- grid
- presenter
- template
database
database
=> 决定从local.neon
中哪个数据库将被使用
- 如果您的项目只使用一个数据库或使用多个数据库但希望使用
default
,它将自动选择,并且不需要此参数
生成的内容
实体
命名空间、类、属性、函数以返回新日期时间对象而不是字符串来处理日期和时间列
存储库
命名空间、类、表和实体属性、重写的getBy和getByID
表单
命名空间、类、存储库、属性、附加(带有检查)、表单、表单成功
网格
命名空间、类、网格、处理程序、编辑表单
展示器
工厂注入、createComponent函数、actionFormEdit
模板
带有控制组件的Latte模板
仪表
命名空间、类、常量、函数 - 需要更改常量和翻译
- 仅从枚举和字符列生成