laraspells / generator
Laravel Crud 生成器
dev-master
2019-01-20 01:09 UTC
Requires
- symfony/yaml: 3.*
Requires (Dev)
- illuminate/support: 5.4
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-09-20 13:03:58 UTC
README
LaraSpell 是一个 Laravel CRUD 生成器,可以生成 Laravel 代码。因此,您可以按需修改生成的文件,没有任何限制。您只需要一些 PHP 和 Laravel 知识就可以自定义它。
演示(视频)
- https://#/em.sifa/videos/2073212012693128/
- https://#/em.sifa/videos/2180691341945194/
- https://#/em.sifa/posts/2212262218788106
特性
- 无限定制
- 仓储模式
- 自定义模板
要求
- php >= 5.6
- composer
- Laravel 5.4
安装
运行以下 composer 命令来安装 laraspells/generator
composer require "laraspells/generator"
现在打开 config/app.php
,将 LaraSpells\Generator\LaraSpellServiceProvider::class
添加到 'providers' 部分。
快速入门
创建一个模式
运行以下命令来创建一个模式
php artisan spell:make admin
此命令将在您的项目目录中生成 admin.yml
修改模式
打开 admin.yml
,按需进行修改。有关模式的更多详细信息,请参阅模式部分。
生成
运行此命令
php artisan spell:generate admin
现在您可以通过将生成的服务提供者添加到 config/app.php
文件中来使用它。
模式
结构
--- name: Schema Name # Schema name (for now it's just for information, not used to generate anything) template: vendor/laraspells/generator/template # Template directory author: name: Author Name # Author name (used for generated PHP classes) email: author@email.example # Author email config_file: admin # Config file to store 'menu' and 'repositories' configuration upload_disk: uploads # Upload disk to store uploaded files provider: file: app/Providers/AdminServiceProvider.php # Provider class filepath class: App\Providers\AdminServiceProvider # Provider class name controller: path: app/Http/Controllers # Path to store generated controller files namespace: App\Http\Controllers # Controller class namespace request: path: app/Http/Requests # Path to store generated requests files namespace: App\Http\Requests # Requests class namespace model: path: app/Models # Path to store model files namespace: App\Models # Model class namespace repository: path: app/Repositories # Path to store repository files class: App\Repositories # Repository class/interface namespace view: path: resources/views # Path to store view files namespace: "" # View namespace route: file: routes/web.php # Path to routes file name: admin:: # Route group name prefix: admin # Route prefix tables: # - List tables - todos: # Table 'todos' schema plural: todos # [optional] Plural name singular: todo # [optional] Singular name label: Todo # Crud label icon: fa-list # Icon class fields: # List fields title: # Field 'title' schema type: string # Field type (for migration) label: Title # Field label length: 80 # [optional] Field length input: text # Field input type (string|assoc) rules: # Field rules - required description: type: text label: Description input: textarea rules: - required status: type: enum:waiting,progress,done # Field type with parameters label: Status input: # Field input type using assoc (with input parameters) type: radios options: waiting: Waiting progress: On Progress done: Done rules: - required - in:waiting,progress,done