A code generator for EasySwoole

Overview

wise-generator-easyswoole

基于EasySwoole的code-generation改写,主要应用与内部系统。基本上所有类都有所调整,同时也完善了一些功能。

版本说明

版本说明

code-generation

使用命令行,一键生成业务通用代码,支持代码如下:

  • 一键生成项目初始化 baseController,baseModel,baseUnitTest.支持自定义ModulePath
  • 一键生成 Model ,自带属性注释,支持自动识别autoTimeStamp、创建时间、更新时间
  • 一键生成 CURD控制器(add/edit/getOne/getList/delete)
  • 一键生成 控制器单元测试用例

安装

composer require mlym/easyswoole-code-generation

改善内容

  1. Contorller的@ApiGroupDescription可以正确读取表的COMMENT信息
  2. Controller和Model可以通过--description 增加功能说明
  3. Controller和Model可以继承同目录的Base类(先通过初始化init --modulePath=\\模块目录 生成Base类)
  4. Controller移除响应注解,由于文档自动生成与实际需求偏差较大,移除了所有Response参数说明
  5. Controller修复注解问题,有效区分@param的alias和description
  6. Controller修复注解问题,修复所有字段都是required="",导致必须填写的问题
  7. Controller移除部分请求注解,如add时ID必填、create_time必填等情况
  8. Controller方法参数调整,为了统一前后端分页字段,将page改为pageNo
  9. Controller和Model的代码简化
  10. Model支持自动识别$autoTimeStamp、$createTime、$updateTime
  11. Model支持自动创建设置器
  12. 增加Options

使用

1. DI注入

bootstrap事件Di注入MySQL配置项:

<?php

\EasySwoole\EasySwoole\Core::getInstance()->initialize();

$mysqlConfig = new \EasySwoole\ORM\Db\Config(\EasySwoole\EasySwoole\Config::getInstance()->getConf('MYSQL'));
\EasySwoole\Component\Di::getInstance()->set('CodeGeneration.connection',$mysqlConfig);

//注入执行目录项,后面的为默认值,initClass不能通过注入改变目录
\EasySwoole\Component\Di::getInstance()->set('CodeGeneration.modelBaseNameSpace',"App\\Model");
\EasySwoole\Component\Di::getInstance()->set('CodeGeneration.controllerBaseNameSpace',"App\\HttpController");
\EasySwoole\Component\Di::getInstance()->set('CodeGeneration.rootPath',getcwd());

执行命令:

php vendor/bin/mlym-easyswoole-code-generator

2.初始化基础类:

php vendor/bin/mlym-easyswoole-code-generator init

无参数示例:
┌────────────┬─────────────────────────────────────────────────────────────────────────────────────────┐
│ className  │                                        filePath                                         │
├────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤
│ Model      │ /Users/ryan/Desktop/src/composer/easyswoole-code-generation/App/Model/BaseModel.php     │
├────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤
│ Controller │ /Users/ryan/Desktop/src/composer/easyswoole-code-generation/App/HttpController/Base.php │
├────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤
│ UnitTest   │ /Users/ryan/Desktop/src/composer/easyswoole-code-generation/UnitTest/BaseTest.php       │
└────────────┴─────────────────────────────────────────────────────────────────────────────────────────┘

参数:

  • --modulePath 模块路径
php vendor/bin/mlym-easyswoole-code-generator init --modulePath=\\admin

参数示例:
┌────────────┬───────────────────────────────────────────────────────────────────────────────────────────────┐
│ className  │                                           filePath                                            │
├────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
│ Model      │ /Users/ryan/Desktop/src/composer/easyswoole-code-generation/App/Model/admin/BaseModel.php     │
├────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
│ Controller │ /Users/ryan/Desktop/src/composer/easyswoole-code-generation/App/HttpController/admin/Base.php │
├────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
│ UnitTest   │ /Users/ryan/Desktop/src/composer/easyswoole-code-generation/UnitTest/admin/BaseTest.php       │
└────────────┴───────────────────────────────────────────────────────────────────────────────────────────────┘

3.自定义业务模块代码:

php vendor/bin/mlym-easyswoole-code-generator all

参数:

  • --tableName 必须指定
  • --modelPath 必须指定 模型
  • --controllerPath 控制器
  • --unitTestPath 单元测试
  • --extendBase 继承同目录Base基类,不需要指定具体值
  • --description 控制器和模型的描述

示例:

$ php vendor/bin/mlym-easyswoole-code-generator all --tableName=mw_user --controllerPath=\\admin --modelPath=\\admin --extendBase --description=用户模块
┌────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ className  │                                              filePath                                              │
├────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Model      │ /Users/ryan/Desktop/src/composer/easyswoole-code-generation/App/Model/admin/MwUserModel.php     │
├────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Controller │ /Users/ryan/Desktop/src/composer/easyswoole-code-generation/App/HttpController/admin/MwUser.php │
└────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┘```

### 4.生成Json中间件
```bash
php vendor/bin/mlym-easyswoole-code-generator json --tableName=mw_test
┌─────────────┬────────────────────────────────────────────────────────────────────────────────────────┐
│    Table    │                                     MiddleFilePath                                     │
├─────────────┼────────────────────────────────────────────────────────────────────────────────────────┤
│ mw_test_one │ /Users/ryan/Desktop/src/composer/easyswoole-code-generation/json_file/mw_test_one.json │
└─────────────┴────────────────────────────────────────────────────────────────────────────────────────┘

参数:

  • --tableName 必须指定
You might also like...
One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP
One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP

otp-thing One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP Introduction This started

This bundle provides new generator command line tools for doctrine generator.

GenBundle This bundle provides new generator command line tools for doctrine generator, extending SensioGeneratorBundle. php bin/console gen:generate:

Documentation generator for PHP Code using standard technology (SRC, DOCBLOCK, XML and XSLT)

phpDox phpDox is a documentation generator for PHP projects. This includes, but is not limited to, API documentation. The main focus is on enriching t

Basic Crud Generator (With Code Files, like GII (YII2)) Using Laravel, Livewire and Tailwind CSS
Basic Crud Generator (With Code Files, like GII (YII2)) Using Laravel, Livewire and Tailwind CSS

LiveCrud Live Crud Generator. This package generates Basic Crud with Livewire. Features Generate Complete Crud With Livewire Component and Blade Files

A command line code generator for Drupal.

Drupal Code Generator A command line code generator for Drupal. Installation Download the latest stable release of the code generator.

Contracts for Rule Doc Generator. Useful for production code with minimum dependencies.

Rule Doc Generator Contracts Contracts for Rule Doc Generator. Useful for production code with minimum dependencies. Install composer require symplify

Laravel Code Generator based on MySQL Database

Laravel Code Generator Do you have a well structed database and you want to make a Laravel Application on top of it. By using this tools you can gener

Algerian code generator for invoices, quotes or any commercial documents

Algerian invoice code generator The library is useful to generate code for invoices, quotes or any commercial transaction document. Goal Is to provide

Magento 2 Code Generator

Magento 2 Code Generator Created by Orba Inspired by https://github.com/staempfli/magento2-code-generator Purpose In day-to-day Magento 2 development

QR Code Generator
QR Code Generator

QR Code By endroid If you like my work you can show appreciation by sponsoring via Github Sponsors or send me some ADA at DdzFFzCqrhszSwiFWMBQomfv6mkD

An intelligent code generator for Laravel framework that will save you time

An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many of the use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.

A Laravel Code Generator based on your Models using Blade Template Engine
A Laravel Code Generator based on your Models using Blade Template Engine

Laravel Code Generator is a PHP Laravel Package that uses Blade template engine to generate code for you. The difference between other code generators

Laravel CRUD Generator, Make a Web Application Just In Minutes, Even With Less Code and fewer Steps !

🚀 CRUDBOOSTER - Laravel CRUD Generator Laravel CRUD Generator, Make a Web Application Just In Minutes, Even With Less Code and fewer Steps ! About CR

Code generator for Magento 2
Code generator for Magento 2

Magento 2 Code Generator Tool Installation Option1: Downloading .phar wget https://github.com/staempfli/magento2-code-generator/releases/download/ver

The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7
The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7

Maghead 4.0.x IS CURRENTLY UNDER HEAVY DEVELOPMENT, API IS NOT STABLE Maghead is an open-source Object-Relational Mapping (ORM) designed for PHP7. Mag

Runtime Code Generator like Lombok for PocketMine-MP
Runtime Code Generator like Lombok for PocketMine-MP

PlumbokPM Runtime Code Generator like Lombok for PocketMine-MP. Code generation starts when additional autoloader detects class uses PlumbokPM annotat

A QR Code generator for PHP7.4+

chillerlan/php-qrcode A PHP 7.4+ QR Code library based on the implementation by Kazuhiko Arase, namespaced, cleaned up, improved and other stuff. Docu

A command line code generator for Drupal

Drupal Code Generator A command line code generator for Drupal.

A full-scale PHP 5.3.2+ sandbox class that utilizes PHPParser to prevent sandboxed code from running unsafe code.
A full-scale PHP 5.3.2+ sandbox class that utilizes PHPParser to prevent sandboxed code from running unsafe code.

##DEPRECATED: The PHPSandbox project has transfered to Corveda/PHPSandbox and will be actively maintained there. This branch is no longer being active

Owner
Ryan
Ryan
:rocket: A Smart CRUD Generator For Laravel

Features Generate your models, views, controllers, routes and migrations just in a few clicks. Models visualization through a graph presentation (New

Houssain Amrani 891 Dec 23, 2022
Laravel API Documentation Generator

Laravel API Documentation Generator Automatically generate your API documentation from your existing Laravel/Lumen/Dingo routes. php artisan apidoc:ge

Marcel Pociot 3.3k Dec 21, 2022
Module Generator Composer Package For Laravel

Module Generator Installation You can install the package via composer: composer require teacoders/module-generator Run the command below to publish t

Tea Coders 21 Jan 8, 2022
Trial account generator for NoPing

NoPing account generator (beta version) Trial account generator for NoPing TODO It is working add some errors checks Add a good readme Host the server

Benjamin 6 Sep 6, 2022
A PHP README File Generator, to generate easily your GitHub README files 🎉

Readme Generator ?? Requiremennts ?? Make sure you have PHP 8.0 or higher installed. Steup ⚙️ Install Composer v2 or higher (https://getcomposer.org)

♚ PH⑦ de Soria™♛ 9 Oct 18, 2022
ICEcoder is a browser based code editor, which provides a modern approach to building websites

ICEcoder Code editor awesomeness ...in your browser ICEcoder is a browser based code editor, which provides a modern approach to building websites. By

ICEcoder 1.4k Dec 18, 2022
swoole,easyswoole,swoole framework

EasySwoole - A High Performance Swoole Framework EasySwoole is a distributed, persistent memory PHP framework based on the Swoole extension. It was cr

null 4.6k Jan 2, 2023
InfyOm Laravel Generator - API, Scaffold, Tests, CRUD Laravel Generator

InfyOm Laravel Generator Generate Admin Panels CRUDs and APIs in Minutes with tons of other features and customizations with 3 different themes. Read

InfyOmLabs (InfyOm Technologies) 3.5k Jan 1, 2023
Laravel CRUD Generator This Generator package provides various generators like CRUD, API, Controller, Model, Migration, View for your painless development of your applications.

Laravel CRUD Generator This Generator package provides various generators like CRUD, API, Controller, Model, Migration, View for your painless develop

AppzCoder 1.3k Jan 2, 2023
Laravel Design Pattern Generator (api generator)

Laravel Design Pattern Generator (api generator) you can create your restful api easily by using this library and you can filter, sort and include elo

HusseinAlaa 2 Sep 25, 2022