2017 © Pedro PelĂĄez
 

library lumen-api-generator

Artisan generator for API reasource.

image

asmiarowski/lumen-api-generator

Artisan generator for API reasource.

  • Monday, March 21, 2016
  • by asmiarowski
  • Repository
  • 2 Watchers
  • 5 Stars
  • 60 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

lumen-api-generator

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., (*1)

Installation

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

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

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

Uncomment in `bootstrap/app.php` , (*3)

 $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:, (*4)

/**
 * Overwrite Laravel Request method because API is always returning json
 * @return bool
 */
public function wantsJson()
{
    return true;
}

Command syntax

php artisan make:api-resource <table_name> --schema="<column_name>:<column_type>(<arguments>):<option>(<arguments>); [...]" --softdeletes

Command options

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

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

Column types

http://laravel.com/docs/5.1/migrations#creating-columns, (*7)

Custom types

- email - puts string type column in your migration and email validation for your request, (*8)

Column options

foreign, index, unique, default, nullable, first, after, unsigned, (*9)

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:, (*10)

app/Http/Controllers/EmailController.php, (*11)

app/Htpp/Requests/EmailRequest.php, (*12)

app/Email.php, (*13)

database/migrations/*timestamp*_create_emails_table.php, (*14)

And appends resource routes to app/routes.php with pattern for id of the resource., (*15)

The Versions

21/03 2016

dev-master

9999999-dev https://github.com/asmiarowski/lumen-api-generator

Artisan generator for API reasource.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artur ƚmiarowski

rest api generators lumen

18/03 2016

v0.3.0

0.3.0.0 https://github.com/asmiarowski/lumen-api-generator

Artisan generator for API reasource.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artur ƚmiarowski

rest api generators lumen

24/12 2015

v0.2.0

0.2.0.0 https://github.com/asmiarowski/laravel5-api-generator

Artisan generator for API reasource.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artur ƚmiarowski

laravel rest api generators

25/10 2015

v0.1.1

0.1.1.0 https://github.com/asmiarowski/laravel5-api-generator

Artisan generator for API reasource.

  Sources   Download

MIT

The Requires

 

by Artur ƚmiarowski

laravel rest api generators