2017 © Pedro Peláez
 

library laravel5-api-generator

Artisan generator for API reasource.

image

asmiarowski/laravel5-api-generator

Artisan generator for API reasource.

  • Sunday, June 4, 2017
  • by asmiarowski
  • Repository
  • 2 Watchers
  • 4 Stars
  • 700 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 7 Versions
  • 10 % Grown

The README.md

laravel5-api-generator

Generates boilerplate for laravel REST API: migration, controller, model, request and route., (*1)

Installation

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

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

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

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

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

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

Column types

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

Custom types

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

- url - puts text type column in your migration and url validation in 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

04/06 2017

dev-master

9999999-dev 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

04/06 2017

v0.4.1

0.4.1.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

04/06 2017

v0.4.0

0.4.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

03/09 2016

v0.3.0

0.3.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

17/08 2016

v0.2.1

0.2.1.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

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