【扩展分享】Laravel 5.3 代码生成器 - summerblue/generator

Laravel 提供了很棒的功能特性,此生成器以构建实战项目为目标,利用这些特性,允许你快速构建健壮性和扩展性兼备的项目。

https://github.com/summerblue/generator

另:此项目遵守 优帆远扬 制定的 Laravel 项目开发规范

功能列表

安装

第一步、通过 Composer 安装

composer require 'summerblue/generator' --dev

第二步、增加服务提供者

打开 /app/Providers/AppServiceProvider.phpregister 方法添加,如下:

public function register()
{
     if (app()->environment() == 'local' || app()->environment() == 'testing') {

        $this->app->register(\Summerblue\Generator\GeneratorsServiceProvider::class);

    }
}

第三步、查看命令

在命令行运行 php artisan 后,查看是否有 make:scaffold 命令。

示例

使用以下命令来构建 Project 模型:

php artisan make:scaffold Projects --schema="name:string:index,description:text:nullable,subscriber_count:integer:unsigned,default(0)"

会输出:

$ php artisan make:scaffold Projects --schema="name:string:index,description:text:nullable,subscriber_count:integer:unsigned:default(0)"

----------- scaffolding: Project -----------

+ ./database/migrations/2017_04_17_065656_create_projects_table.php
+ ./database/factories/ModelFactory.php
+ ./database/seeds/ProjectsTableSeeder.php
+ ./database/seeds/DatabaseSeeder.php (Updated)
x ./app/Models/Model.php (Skipped)
+ ./app/Models/Project.php
+ ./app/Http/Controllers/ProjectsController.php
x ./app/Http/Requests/Request.php (Skipped)
+ ./app/Http/Requests/ProjectRequest.php
+ ./app/Observers/ProjectObserver.php
+ ./app/Providers/AppServiceProvider.php (Updated)
x ./app/Policies/Policy.php
+ ./app/Policies/ProjectPolicy.php
+ ./app/Providers/AuthServiceProvider.php (Updated)
+ ./routes/web.php (Updated)

--- Views ---
   + create_and_edit.blade.php
   + index.blade.php
   + show.blade.php
x ./resources/views/error.blade.php
Migrated: 2017_04_17_065656_create_projects_table

----------- -------------------- -----------
-----------   >DUMP AUTOLOAD<    -----------

效果图

file

未来计划

  • API
  • Admin
  • Auto fill FormRequest rule
  • Auto fill ModelFactory filed

感谢


:book: Laravel 书籍: