laravelha / generator
Laravelha Generator
v2.0.1
2020-10-18 22:50 UTC
Requires
- ext-dom: *
- doctrine/dbal: ^2.10
- illuminate/console: ^8.0
- illuminate/filesystem: ^8.0
- illuminate/support: ^8.0
- laravelha/support: ^1.0
- orangehill/iseed: ^2.6
README
基于 Laravel-5-Generators-Extended 的 Laravel RAD 包
安装
安装完新的 Laravel 应用程序后
- 安装预设
composer require laravelha/preset-api --dev
或composer require laravelha/preset-web --dev
- 运行预设
php artisan preset ha-api
或php artisan preset ha-web --option=auth
- 通过
composer require laravelha/generator --dev
- 运行
php artisan ha-generator:<COMMAND> <ARGUMENTS> <OPTIONS>
以自动生成代码。 - 以下命令可用。
ha-generator:migration "Create a new migration class and apply schema at the same time" ha-generator:model "Create a new model class and apply schema at the same time" ha-generator:factory "Create a new factory class and apply schema at the same time" ha-generator:requests "Create a new requests class and apply schema at the same time" ha-generator:controller "Create a new controller and resources for api" ha-generator:resources "Create a new resources class and apply schema at the same time" ha-generator:route "Insert new resources routes" ha-generator:test "Create a new feature test and apply schema at the same time" ha-generator:lang "Create a new lang resource and apply schema at the same time" ha-generator:view "Create a new views resource and apply schema at the same time" ha-generator:breadcrumb "Insert new resources breadcrumb" ha-generator:nav "Insert new nav item" ha-generator:crud "Run all commands" ha-generator:existing:crud "Run all commands from a existing database" ha-generator:package "Create scaffolding structure to packages"
- 有关每个命令的更多信息,请使用:
php artisan help ha-generator:<COMMAND>
快乐方式
这是我的使用方法。
- 安装 Laravel 新应用程序
composer create-project --prefer-dist laravel/laravel blog && cd blog
- 进行第一次提交
git init git add . git commit -m 'feat: install laravel fresh app'
- 为您的案例安装 Laravelha/Preset
composer require laravelha/preset-web --dev
- 运行预设
php artisan preset ha-web --option=auth
- 进行提交
git add . git commit -m 'feat: install and run laravel laravelha/preset-web with auth'
- 安装生成器并发布配置
composer require laravelha/generator --dev php artisan vendor:publish --tag=ha-generator
- 运行 CRUD 生成器
php artisan ha-generator:crud Category -s 'title:string(150), description:text:nullable, published_at:timestamp:nullable'
- 然后进行提交
git add . git commit -m 'feat: create category crud by generator'
- 运行其他 CRUD 生成器
php artisan ha-generator:crud Post -s 'title:string(150), content:text, published_at:timestamp:nullable, category_id:unsignedBigInteger:foreign'
- 最后提交 CRUD
git add . git commit -m 'feat: create post crud by generator'
在运行生成器之前保持阶段清洁非常重要,因为如果您放弃已生成的代码,可以使用
git clean -fd; git checkout .
完全撤销。
每个生成的命令都存储在 /storage/logs 中,如果您需要更详细的 CRUD 命令,请使用选项
--log-details
自动生成的结构
app/
├── <SINGULAR_CLASS_NAME>.php
│
└── Http
├── Controllers
| ├── Auth
| ├── IndexController.php
| └── <SINGULAR_CLASS_NAME>Controller.php
|
└── Requests
└── Requests
├── <SINGULAR_CLASS_NAME>StoreRequest.php
└── <SINGULAR_CLASS_NAME>UpdateRequest.php
config/
└── ha-generator.php
database
├── factories
| └── <SINGULAR_CLASS_NAME>Factory.php
|
└── migrations
└── YYYY_MM_DD_HHmmSS_create_<PLURAL_CLASS_NAME>_table.php
resources
├── lang/pt-br
| └── <PLURAL_CLASS_NAME>.php
|
└── views
└── <PLURAL_CLASS_NAME>
├── create.blade
├── delete.blade
├── edit.blade
├── index.blade
└── show.blade
routes
├── api.php
├── breadcrumbs.php
└── web.php
示例
API 从生成器生成的 API
WEB 从生成器生成的 Web 应用程序