asmiarowski/lumen-api-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

asmiarowski/lumen-api-generator

Composer 安装命令:

composer require asmiarowski/lumen-api-generator

包简介

Artisan generator for API reasource.

README 文档

README

Generates boilerplate for lumen REST API: migration, controller, model, request and route. Generator creates Eloquent Models and use them in generated controllers. If you want to use this package you are encouraged to uncomment $app->withEloquent in bootstrap/app.php.

Installation

``` composer require --dev asmiarowski/lumen-api-generator ```

Add this to app\Providers\AppServiceProvider inside register() method:

``` if ($this->app->environment() == 'local') { $this->app->register('Smiarowski\Generators\GeneratorsServiceProvider'); } ```

Uncomment in `bootstrap/app.php`

``` $app->register(App\Providers\AppServiceProvider::class); ``` For POST / PUT data to work you either have to send your request with `Accept: application/json` header or set up json responses globally in app/Http/Requests/Request.php like so: ``` /** * Overwrite Laravel Request method because API is always returning json * @return bool */ public function wantsJson() { return true; } ```

Command syntax

``` php artisan make:api-resource --schema=":():(); [...]" --softdeletes ```

Command options

--schema - required, schema of your migration, validators will be set based on fields and types specified.

--softdeletes - optional, add softDeletes() to migration

Column types

http://laravel.com/docs/5.1/migrations#creating-columns

Custom types

- email - puts string type column in your migration and email validation for your request

Column options

foreign, index, unique, default, nullable, first, after, unsigned

Example command

``` php artisan make:api-resource emails --schema="email:email:unique; title:string; body:text; status:integer:default(1); user_id:integer:foreign(users)" --softdeletes ```

Creates:

app/Http/Controllers/EmailController.php

app/Htpp/Requests/EmailRequest.php

app/Email.php

database/migrations/*timestamp*_create_emails_table.php

And appends resource routes to app/routes.php with pattern for id of the resource.

统计信息

  • 总下载量: 81
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固