Download the PHP package lvzhao1995/code-generate without Composer

On this page you can find all versions of the php package lvzhao1995/code-generate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package code-generate

代码生成工具(适用于Vue)

代码生成工具主要用于生成后端开发中简单的增删改查代码,复杂的逻辑还需自己实现,不过你无须担心,我们通过简单的封装简化了开发流程,即便你是新手,也可以写出出色的代码。

工具基于ThinkPHP 5.1开发。

此版本前端使用iview-admin作为UI组件库,配置完善之后会向yapi中自动写入文档。

安装

生成工具的开启

项目根目录下运行 php think generate命令即可;开发期间根目录下生成的generate.lock不可删除。

框架说明

框架核心功能为代码生成;主要分为两个大的模块,即前台,后台;目前数据库的操作均为ThinkPHP 5.0中的模型方式。

关于性能

为了优化查询性能,默认全部的数据库查询走缓存方式,当然,你也可以在控制器中自己选择是否开启;对此也解决了在执行数据库的增,改,删操作的时候,缓存也会即时刷新,前提是你必须使用model的方式。

如何使用

操作之前请先完善数据表,以下全部操作都是基于数据表的字段。

名词解释

开启生成工具

在项目根目录执行以下命令:

执行完毕后访问项目域名/generate即可。

配置文件

选项说明

此章节针对生成工具界面上的选项进行简单说明

关于生成文档

在正确配置env.php中的内容后,生成前台时如果选择生成控制器,则会同时向yapi中写入文档,文档根据生成时配置的允许的操作 名称 操作 必填等内容进行,文档中已有的接口不会被覆盖,统一生成到临时分类中,请自行调整分类并检查文档是否正确。

生成内容

数据库相关操作均使用ThinkPHP 5.0的模型操作,具体参考ThinkPHP 5.0文档

后台

protected $modelName  = '模型名'; 
protected $indexField = ['列表页要显示字段']; 在日常开发中,我们需要在列表中追加表格的列,首先我们需要在这里进行编辑
protected $addField = ['新增页面的表单输入字段'];
protected $editField = ['编辑页面的表单输入字段'];
/**
 * 条件查询,字段名,例如:无关联查询['name','age'],关联查询['name','age',['productId' => 'product.name']],解释:参数名为productId,关联表字段p.name
 * 默认的类型为输入框,如果有下拉框,时间选择等需求可以这样定义['name',['type' => ['type','select']]];目前有select,time_start,time_end三种可被定义
 * 通过模型定义的关联查询,可以这样定义['name',['memberId'=>['member.nickname','relation']]],只能有一个被定义为relation,且字段前的表别名必须为关联的方法名
 * @var array
 */
protected $searchField = [];
protected $pageSize = 10;                 //当前页面显示的数据数量,用于分页
//添加数据验证规则,参考tp5的验证规则
protected $add_rule = [
    'nickName|昵称'  => 'require|max:25'
];
//编辑数据验证规则,参考tp5的验证规则
protected $edit_rule = [
    'nickName|昵称'  => 'require|max:25'
];

前台

模型

当前版本生成的模型,全部位于\app\common\model,前后台使用统一的模型类。具体属性含义,请参考模型内注释和ThinkPHP 5.0文档。

前台接口

默认提供四个接口,路径一致,通过请求方式和参数进行区分,不影响自定义的方法,详见下方表格:

地址 请求方式 响应方法 备注
/app/控制器/index get get 查询。传入id时返回详情,字段按照$detailField定义的返回;
否则返回列表,字段按照$indexField定义的返回。
/app/控制器/index post post 新增
/app/控制器/index put put 修改
/app/控制器/index delete delete 删除

数据返回

目前工具封装了统一的返回方法,位于\Generate\Traits\JsonReturn,提供了以下方法

项目上线

参考文档


All versions of code-generate with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
ext-json Version *
ext-mbstring Version *
topthink/framework Version 5.1.*
guzzlehttp/guzzle Version ^6.3 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lvzhao1995/code-generate contains the following files

Loading the files please wait ....