New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

asmiarowski/laravel5-api-generator

Artisan generator for API reasource.
1,756 4

Larablocks Analysis

asmiarowski/laravel5-api-generator is built for Laravel 5, going by its name (latest release v0.4.1, Jun 4, 2017), which reached end of life: no more fixes, even for security.

Laravel 5 in earlier releases.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 5, past end of life
  • No release in the last 12 months (last: Jun 4, 2017)
  • 0 downloads a month (needs 10,000)
  • 4 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Jun 4, 2017.
  • No releases in the last 12 months.
  • First released: Oct 25, 2015.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 4, 2026.

Install
composer require asmiarowski/laravel5-api-generator
Latest Version:v0.4.1
PHP:>=5.5.0
Older releases:5
License:MIT
Last Updated:Jun 4, 2017
Links: GitHub  ·  Packagist
Maintainer: asmiarowski

laravel5-api-generator

Generates boilerplate for laravel REST API: migration, controller, model, request and route.

Installation

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

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

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:

/**
 * 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.

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

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

Related Packages

asmiarowski/lumen-api-generator

Artisan generator for API reasource.

81 6
laracasts/generators

Advanced Laravel generators, that include schema information.

6,632,692 2,412
laracademy/generators

This package will generate a Laravel Model based on your database table itself,...

406,322 353
onesite/laravel-module

Generate a module with model, migration, controller, routes and factory

3,390 0
sain2424/generators

Extend Laravel 5's generators.

1,900 0

Version History

Version Released PHP Laravel License
v0.4.1 >=5.5.0 MIT
v0.4.0 >=5.5.0 MIT
v0.3.0 >=5.5.0 MIT
v0.2.1 >=5.5.0 MIT
v0.2.0 >=5.5.0 ^5.2 MIT