Download the PHP package yunjuji/yunjuji-generator without Composer
On this page you can find all versions of the php package yunjuji/yunjuji-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download yunjuji/yunjuji-generator
More information about yunjuji/yunjuji-generator
Files in yunjuji/yunjuji-generator
Download yunjuji/yunjuji-generator
More information about yunjuji/yunjuji-generator
Files in yunjuji/yunjuji-generator
Vendor yunjuji
Package yunjuji-generator
Short Description yunjuji generator
License MIT
Homepage https://github.com/tiandaye/yunjuji-generator
Package yunjuji-generator
Short Description yunjuji generator
License MIT
Homepage https://github.com/tiandaye/yunjuji-generator
Please rate this library. Is it a good library?
Informations about the package yunjuji-generator
Yunjuji Generator
github或者码云上拉取目录使用说明
目录说明
- model.csv【字段信息文件, 和你的实体同级,必须】【具体规则参考
csv说明
】 - model.json【自己的命名空间, 和实体同级,必须】【具体规则参考
model.json文件
】 - filter.json【过滤字段文件, 和你的实体同级,非必须】【具体规则参考
过滤字段json文件
】 - namespace_model_mapping.json【命名空间映射关系,一个项目只需要一个,放在根目录, 非必须】【具体参考
命名空间映射json文件
】csv说明
注意点
- 多个字段之间统一用
;
分隔, 最后一个字段不要加;
。 created_at
,updated_at
,id
字段默认添加, 不需要重新指定。fields
,foriegns
,inForms
等所有属性可以不按顺序, 并且可以根据实际情况选填。比如没有关联关系的模型relations
属性就没有。- 所有的例子以 媒资点播类资产为例
- 多个字段之间统一用
字段详情
- fields-字段列表
- 说明:fields:【字段】【格式:字段名:字段别名;】 vasset_no: 视频编号; name: 名称; title: 标题; subtitle: 副标题; spell: 拼音; short_desc: 简述; long_desc: 详述; score: 评分; expiring_at: 失效日期; online_at: 上线日期; offline_at: 下线日期; published_at: 发布日期; season: 第几季; episode: 共几集; latest: 最近更新
- foriegns-外键
- 说明:foriegns:【外键】【格式:字段名:表名(注意一般的表名都是下划线命名法, 并且加s), 映射字段名(如果相同可以省略);】 vcat_no: vcats; vseason_no: vseasons, vseason_no; vyearcat_no: vyearcats; vareacat_no: vareacats; vareacat_no: vareacats; vlangcat_no: vlangcats
- tags-关联关系
- 说明:tags:【标签】【格式:模型名(大写,没s), 中间表名, 映射关系】 "mtm,Role,user_roles,user_id,role_id"【设计有问题】
- relations-关联关系
- 说明:relations:【关联关系】【格式: 关联关系类型(1t1:一对一, 1tm:一对多, mt1:反向一对多, m2m:多对多, hmt:远程一对多, mht:多态关联, mhm, mhtm, mhbm), 模型名(大写, 没s), 映射关系(具体分析)】 "1tm,Writer,writer_id,id"【设计有问题】
- query【暂不处理】
- sortby【暂不处理】
- inForms-是否在form中显示
- 说明:inForms: 【需要在编辑form里面显示的字段】【格式:字段名;】 vasset_no;name;title;subtitle;spell;short_desc;long_desc;score;expiring_at;online_at;offline_at;published_at;season;episode;latest
- inIndexs-是否在table中显示
- 说明:inIndexs:【是否需要在表格里面显示字段】【格式:字段名;】 vasset_no;name;title;subtitle;spell;short_desc;long_desc;score;expiring_at;online_at;offline_at;published_at;season;episode;latest
- validations-校验
- 说明:validations:【校验】【格式:字段名:校验规格(多个校验规则用|);】 vasset_no:required|max:100;name:required;title:required;subtitle:required;spell:required
- htmlTypes-表单控件
- 说明:htmlTypes:【控件类型】【格式:字段名:控件类型 】 vasset_no:text;name:text;title:text;subtitle:text;spell:text;short_desc:text;long_desc:textarea;score:number;expiring_at:datetime;online_at:datetime;offline_at:datetime;published_at:datetime;season:text;episode:text;latest:text
- dbTypes-数据库字段类型
- 说明:dbTypes:【数据库字段类型】【格式:字段名:字段类型,字段长度(可选, 如果没有长度则
,
和 字段长度都可以不要);】 vasset_no:string, 100;name:string, 100;title:string, 100;subtitle:string, 100;spell:string, 100;short_desc:string, 100; long_desc:text; score: decimal,10,2; expiring_at: timestamp;online_at: timestamp;offline_at:timestamp;published_at:timestamp;season:string, 10;episode:string, 10;latest:string, 10
- 说明:dbTypes:【数据库字段类型】【格式:字段名:字段类型,字段长度(可选, 如果没有长度则
- nullables-能否为null
- 说明:nullables:【能否为null】【格式:字段名;】 score;expiring_at;online_at;offline_at;published_at;season;episode;latest
- indexs-是否为索引
- 说明:indexs:【索引】【格式:字段名;(复合索引目前没考虑)】
vasset_no;name;title;subtitle;spell;short_desc;long_desc;score
json文件说明
model.json文件
- 格式说明:#
- json格式:整个文件是一个
{}
- 参数说明
- model_name:模型名(首字母大写)
- perfix_name:目录结构
- title:模型的中文名
- 例子
- 说明:indexs:【索引】【格式:字段名;(复合索引目前没考虑)】
vasset_no;name;title;subtitle;spell;short_desc;long_desc;score
过滤字段json文件
- 格式说明:#
- json格式. 整个文件是一个
[]
- json格式. 整个文件是一个
- 参数说明
- label-标题
- name-字段名
- operator-操作符
- equal: 等于
- notEqual: 不等于
- like: 模糊匹配
- ilike: 不区分大小写
- gt: 大于
- lt: 小于
- between: 范围(可以跟
time
或datetime
等控件连用) - in: 某个范围内(和
multipleSelect
控件连用) - notIn: 不在某个范围(和
multipleSelect
控件连用) - date: date
- month: month
- year: year
- where: 就需要自己写了(现在不支持这个)
- htmlType-控件类型
- select: 下拉框
- multipleSelect: 多选(一般用来配合in和notIn两个需要查询数组的查询类型使用,也可以在where类型的查询中使用)
- datetime: 日期
- date: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'YYYY-MM-DD'])
- time: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'HH:mm:ss'])
- day: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'DD'])
- month: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'MM'])
- year: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'YYYY'])
- 例子
命名空间映射json文件
- 格式说明#
- json格式.
key-value
形式,key
表示模型名
,value
表示命名空间
, 整个文件是一个{}
- json格式.
- 参数说明
- 参数: 无.
- 例子
字段json文件【不需要看这个】
- 格式说明:#
- json格式. 整个文件是一个
[]
- json格式. 整个文件是一个
- 参数说明
- name-字段名, string
- label-表单label, string
- title-表格title, string
- dbType-数据库类型, string, 支持的所有字段类型, 请参考该链接#
- htmlType-控件类型, string, 支持的所有控件类型, 请参考该链接#
- validations-校验, string, 支持的所有验证规则, 请参考该链接#
- relation-关联关系, string, 支持的所模型关联关系, 请参考该链接#
- displayField-表格里面显示关联关系的字段值, string, 格式:模型名+key+value
- fillable-是否支持批量操作, bool
- primary-是否为主键, bool
- inForm-是否在表单里面显示, bool
- inIndex-是否在表格里显示, bool
- options-扩展的参数, string
- searchable-可搜索的字段【目前没用】
- 例子
安装
安装自动产生的依赖
-
在
composer.json
中引入 - 执行
composer update
-
在
config/app.php
的providers
加入 -
在
config/app.php
的aliases
加入 - 依次执行
引入自定义路由
- 在
app/routes
目录下面新建web
文件夹 -
在
app/Providers/RouteServiceProvider.php
的map()
函数中加入 - 在
app/Providers/RouteServiceProvider.php
加入下面两个函数
安装 laravel-admin
首先确保安装好了 laravel
,并且数据库连接设置正确。
然后运行下面的命令来发布资源:
在该命令会生成配置文件 config/admin.php
,可以在里面修改安装的地址、数据库连接、以及表名,建议都是用默认配置不修改。
生成如下文件:
建议将 config/admin.php
里面的 database
部分的表名添加 laravel_
前缀. 一共九张表.
然后运行下面的命令完成安装:
生成的文件:
正式安装 yunjuji/yunjuji-generator
-
开发阶段使用下面命令
- 卸载
composer remove yunjuji/yunjuji-generator
使用
生成脚手架(cms), 使用下面命令
生成
laravel-admin
模板(下面给的是例子, 安装完成之后执行下列命令是ok的) - 基本
php artisan yunjuji:scaffold ContentTemplateType --fieldsFile=./vendor/yunjuji/yunjuji-generator/samples/content_template_type.json --datatables=true --formMode=laravel-admin --prefix=Operation
- 如果有引用模型,则需要添加模型的
命令空间映射
选项(namespaceModelMappingFile
)php artisan yunjuji:scaffold ContentTemplate --fieldsFile=./vendor/yunjuji/yunjuji-generator/samples/content_template.json --namespaceModelMappingFile=./vendor/yunjuji/yunjuji-generator/samples/namespace_model_mapping.json --datatables=true --formMode=laravel-admin --prefix=Operation
- 如果需要自定义过滤区域
php artisan yunjuji:scaffold ContentTemplate --fieldsFile=./vendor/yunjuji/yunjuji-generator/samples/content_template.json --filterFieldsFile=./vendor/yunjuji/yunjuji-generator/samples/filter.json --namespaceModelMappingFile=./vendor/yunjuji/yunjuji-generator/samples/namespace_model_mapping.json --datatables=true --formMode=laravel-admin --prefix=Operation
生成
datatables
模板 php artisan yunjuji:scaffold posts --fieldsFile=./vendor/yunjuji/yunjuji-generator/samples/fields_sample.json --paginate=20 --datatables=true --prefix=v1
参数说明
命令行说明
yunjuji:generateFieldJson 命令, 批量生成
field.json
- 命令说明
- 批量产生
field.json
, 通过model.csv
文件生成fields.json
:php artisan yunjuji:generateFieldJson $PATH
- 批量产生
- 命令选项说明
- 无
- 命令参数说明
$PATH
- 目录的绝对路径yunjuji:generate 命令, 批量生成脚手架
- 命令说明
- 批量产生脚手架, 通过遍历目录的
fields.json
和model.json
:php artisan yunjuji:generate $PATH $GENERATE_PATH?
- 批量产生脚手架, 通过遍历目录的
- 命令选项说明
- 无
- 命令参数说明
$PATH
- 目录的绝对路径$GENERATE_PATH
- 可选, 生成代码的路径yunjuji:rollback命令, 批量回滚
- 命令说明
- 批量回滚, 通过遍历目录的
fields.json
和model.json
:php artisan yunjuji:rollback $PATH
- 批量回滚, 通过遍历目录的
- 命令选项说明
- 无
- 命令参数说明
$PATH
- 目录的绝对路径infyom:rollback命令, 单个回退
- 命令说明
- 单个脚手架回退:
php artisan infyom:rollback $MODEL_NAME $COMMAND_TYPE
- 单个脚手架回退:
- 命令选项说明
--prefix
: 命名空间前缀
- 命令参数说明
$MODEL_NAME
- 模型名$COMMAND_TYPE
- Command type from api, scaffold or api_scaffoldyunjuji:scaffold命令, 单个脚手架生成
- 命令说明
- 生成脚手架:
php artisan yunjuji:scaffold $MODEL_NAME
- 生成脚手架:
- 命令选项说明
--fieldsFile
: 字段文件, 包括form
和grid
. 字段文件格式说明#--filterFieldsFile
: 过滤字段文件. 过滤字段文件格式说明#--namespaceModelMappingFile
: 命名空间映射文件. 命名空间映射文件格式说明#--prefix
: 命名空间前缀--generatePath
: 生成代码的路径
- 命令参数说明
$MODEL_NAME
- 模型名yunjuji:publish命令, 发布
- 命令说明
- 将自动生成的文件发布到指定目录:
php artisan yunjuji:publish $SOURCE_PATH $TARGET_PATH
- 将自动生成的文件发布到指定目录:
- 命令选项说明
- 无
- 命令参数说明
$SOURCE_PATH
- 源目录的绝对路径$TARGET_PATH
- 目标目录的绝对路径yunjuji:fillData命令, 批量填充数据
- 命令说明
- 批量填充数据:
php artisan yunjuji:fillData $PATH
- 批量填充数据:
- 命令选项说明
- 无
- 命令参数说明
$PATH
- 目录的绝对路径yunjuji:dropTable命令, 批量删表
- 命令说明
- 批量填充数据:
php artisan yunjuji:dropTable $PATH
- 批量填充数据:
- 命令选项说明
- 无
- 命令参数说明
$PATH
- 目录的绝对路径csv说明
注意点
- 多个字段之间统一用
;
分隔, 最后一个字段不要加;
。 created_at
,updated_at
,id
字段默认添加, 不需要重新指定。fields
,foriegns
,inForms
等所有属性可以不按顺序, 并且可以根据实际情况选填。比如没有关联关系的模型relations
属性就没有。- 所有的例子以 媒资点播类资产为例
- 多个字段之间统一用
字段详情
- fields-字段列表
- 说明:fields:【字段】【格式:字段名:字段别名;】 vasset_no: 视频编号; name: 名称; title: 标题; subtitle: 副标题; spell: 拼音; short_desc: 简述; long_desc: 详述; score: 评分; expiring_at: 失效日期; online_at: 上线日期; offline_at: 下线日期; published_at: 发布日期; season: 第几季; episode: 共几集; latest: 最近更新
- foriegns-外键
- 说明:foriegns:【外键】【格式:字段名:表名(注意一般的表名都是下划线命名法, 并且加s), 映射字段名(如果相同可以省略);】 vcat_no: vcats; vseason_no: vseasons, vseason_no; vyearcat_no: vyearcats; vareacat_no: vareacats; vareacat_no: vareacats; vlangcat_no: vlangcats
- tags-关联关系
- 说明:tags:【标签】【格式:模型名(大写,没s), 中间表名, 映射关系】 "mtm,Role,user_roles,user_id,role_id"【设计有问题】
- relations-关联关系
- 说明:relations:【关联关系】【格式: 关联关系类型(1t1:一对一, 1tm:一对多, mt1:反向一对多, m2m:多对多, hmt:远程一对多, mht:多态关联, mhm, mhtm, mhbm), 模型名(大写, 没s), 映射关系(具体分析)】 "1tm,Writer,writer_id,id"【设计有问题】
- query【暂不处理】
- sortby【暂不处理】
- inForms-是否在form中显示
- 说明:inForms: 【需要在编辑form里面显示的字段】【格式:字段名;】 vasset_no;name;title;subtitle;spell;short_desc;long_desc;score;expiring_at;online_at;offline_at;published_at;season;episode;latest
- inIndexs-是否在table中显示
- 说明:inIndexs:【是否需要在表格里面显示字段】【格式:字段名;】 vasset_no;name;title;subtitle;spell;short_desc;long_desc;score;expiring_at;online_at;offline_at;published_at;season;episode;latest
- validations-校验
- 说明:validations:【校验】【格式:字段名:校验规格(多个校验规则用|);】 vasset_no:required|max:100;name:required;title:required;subtitle:required;spell:required
- htmlTypes-表单控件
- 说明:htmlTypes:【控件类型】【格式:字段名:控件类型 】 vasset_no:text;name:text;title:text;subtitle:text;spell:text;short_desc:text;long_desc:textarea;score:number;expiring_at:datetime;online_at:datetime;offline_at:datetime;published_at:datetime;season:text;episode:text;latest:text
- dbTypes-数据库字段类型
- 说明:dbTypes:【数据库字段类型】【格式:字段名:字段类型,字段长度(可选, 如果没有长度则
,
和 字段长度都可以不要);】 vasset_no:string, 100;name:string, 100;title:string, 100;subtitle:string, 100;spell:string, 100;short_desc:string, 100; long_desc:text; score: decimal,10,2; expiring_at: timestamp;online_at: timestamp;offline_at:timestamp;published_at:timestamp;season:string, 10;episode:string, 10;latest:string, 10
- 说明:dbTypes:【数据库字段类型】【格式:字段名:字段类型,字段长度(可选, 如果没有长度则
- nullables-能否为null
- 说明:nullables:【能否为null】【格式:字段名;】 score;expiring_at;online_at;offline_at;published_at;season;episode;latest
- indexs-是否为索引
- 说明:indexs:【索引】【格式:字段名;(复合索引目前没考虑)】
vasset_no;name;title;subtitle;spell;short_desc;long_desc;score
json文件说明
字段json文件
- 格式说明:#
- json格式. 整个文件是一个
[]
- 参数说明
- name-字段名, string
- label-表单label, string
- title-表格title, string
- dbType-数据库类型, string, 支持的所有字段类型, 请参考该链接#
- htmlType-控件类型, string, 支持的所有控件类型, 请参考该链接#
- validations-校验, string, 支持的所有验证规则, 请参考该链接#
- relation-关联关系, string, 支持的所模型关联关系, 请参考该链接#
- displayField-表格里面显示关联关系的字段值, string, 格式:模型名+key+value
- fillable-是否支持批量操作, bool
- primary-是否为主键, bool
- inForm-是否在表单里面显示, bool
- inIndex-是否在表格里显示, bool
- options-扩展的参数, string
- searchable-可搜索的字段【目前没用】
- 例子
- 说明:indexs:【索引】【格式:字段名;(复合索引目前没考虑)】
vasset_no;name;title;subtitle;spell;short_desc;long_desc;score
过滤字段json文件
- 格式说明:#
- json格式. 整个文件是一个
[]
- json格式. 整个文件是一个
- 参数说明
- label-标题
- name-字段名
- operator-操作符
- equal: 等于
- notEqual: 不等于
- like: 模糊匹配
- ilike: 不区分大小写
- gt: 大于
- lt: 小于
- between: 范围(可以跟
time
或datetime
等控件连用) - in: 某个范围内(和
multipleSelect
控件连用) - notIn: 不在某个范围(和
multipleSelect
控件连用) - date: date
- month: month
- year: year
- where: 就需要自己写了(现在不支持这个)
- htmlType-控件类型
- select: 下拉框
- multipleSelect: 多选(一般用来配合in和notIn两个需要查询数组的查询类型使用,也可以在where类型的查询中使用)
- datetime: 日期
- date: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'YYYY-MM-DD'])
- time: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'HH:mm:ss'])
- day: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'DD'])
- month: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'MM'])
- year: 作用和下列代码类似, $filter->equal('column')->datetime(['format' => 'YYYY'])
- 例子
命名空间映射json文件
- 格式说明#
- json格式.
key-value
形式,key
表示模型名
,value
表示命名空间
, 整个文件是一个{}
- json格式.
- 参数说明
- 参数: 无.
- 例子
本项目目前支持的能力集
- 表(migration), 说明:相当于数据库里的表字段的定义, 作用:建表
- 字段类型和长度, 具体支持参考字段类型, 里面有的类型都支持
- 支持能否为null
- 索引
- 外键
- 模型(Models), 说明:表的orm
- 1对1关联, 具体的支持参考模型关联关系, 里面有的类型都支持
- 1对多关联
- 反向一对多关联
- 多对多关联
- 远程一对多
- 多态关联
- 多态多对多关联
- 仓库(Repositories), 说明:对模型的一层封装
- 使用
prettus/l5-repository
对模型进行了一层封装, 模型新建
和修改
操作的时候用了,目的是将一些逻辑抽离出来,避免控制器和模型冗余
- 使用
- 请求(Requests), 说明:http请求的依赖注入,做一些数据合法性校验(比如: 非空必填, 长度限制等)
- 支持的校验规则参考可用的验证规则#, 里面有的都支持
-
路由(routes), 说明:定义uri
- 产生crud的路由,现在会产生8项路由 例子如下:
- 控制器(Controllers)
- 基本的curd功能
- 表格(我们基本喜欢叫grid或者table)
- 表单(form)
- 支持的控件类型
- 具体支持的控件类型参考支持的控件类型
- 支持的控件类型
- 批量删除
- 过滤区域
本项目目前还在开发的能力集
暂无
All versions of yunjuji-generator with dependencies
PHP Build Version
Package Version
The package yunjuji/yunjuji-generator contains the following files
Loading the files please wait ....