2017 © Pedro Peláez
 

library apigenerator

API Generator for Laravel 5

image

laraveldaily/apigenerator

API Generator for Laravel 5

  • Monday, July 16, 2018
  • by Laraveldaily
  • Repository
  • 9 Watchers
  • 45 Stars
  • 414 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 0 Open issues
  • 9 Versions
  • 13 % Grown

The README.md

API Generator for Laravel 5.4 and above

Package to create API Controller and Route entry with one Artisan command., (*1)

For now we're starting with only one simple command and will expand functionality as needed. Please submit your suggestions in Issues section., (*2)

Notice: if you want to generate not only API, but full admin panel - check out our QuickAdminPanel.com, (*3)

Installation and Usage

  1. Install the package via composer require laraveldaily/apigenerator, (*4)

  2. Add Laraveldaily\Apigenerator\ApiGeneratorProvider::class to your config\app.php providers., (*5)

  3. That's it: run php artisan make:api --model=XXXXX where XXXXX is your model name., (*6)

This command will generate API Controller and new entry in routes/api.php file., (*7)

Notice: Model should exist already, our package won't create it., (*8)

Example, (*9)

php artisan make:api --model=Project, (*10)

Will generate the file app\Http\Controllers\Api\ProjectsController.php:, (*11)

<?php

namespace App\Http\Controllers\Api;

use App\Project;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ProjectsController extends Controller
{
    public function index()
    {
        return Project::all();
    }

    public function store(Request $request)
    {
        $project = Project::create($request->all());

        return $project;
    }

    public function show($id)
    {
        return Project::findOrFail($id);
    }

    public function update(Request $request, $id)
    {
        $project = Project::findOrFail($id);
        $project->update($request->all());

        return $project;
    }

    public function destroy($id)
    {
        $project = Project::findOrFail($id);
        $project->delete();

        return '';
    }
}

And this line will be added to routes/api.php:, (*12)

Route::resource('projects', 'Api/ProjectsController', ['except' => ['create', 'edit']]);

License

The MIT License (MIT). Please see License File for more information., (*13)


More from our LaravelDaily Team

The Versions

16/07 2018

dev-master

9999999-dev

API Generator for Laravel 5

  Sources   Download

MIT

The Requires

 

by PovilasKorop
by KarolisNarkevicius

16/07 2018

0.1.8

0.1.8.0

API Generator for Laravel 5

  Sources   Download

MIT

The Requires

 

by PovilasKorop
by KarolisNarkevicius

02/07 2018

0.1.7

0.1.7.0

API Generator for Laravel 5

  Sources   Download

MIT

The Requires

 

by PovilasKorop
by KarolisNarkevicius

08/09 2017

0.1.6

0.1.6.0

API Generator for Laravel 5

  Sources   Download

MIT

The Requires

 

by PovilasKorop
by KarolisNarkevicius

04/08 2017

0.1.5

0.1.5.0

API Generator for Laravel 5

  Sources   Download

MIT

The Requires

 

by PovilasKorop
by KarolisNarkevicius

27/07 2017

0.1.3

0.1.3.0

API Generator for Laravel 5

  Sources   Download

MIT

The Requires

 

by PovilasKorop
by KarolisNarkevicius

27/07 2017

0.1.2

0.1.2.0

API Generator for Laravel 5

  Sources   Download

MIT

The Requires

 

by PovilasKorop
by KarolisNarkevicius

27/07 2017

0.1.1

0.1.1.0

API Generator for Laravel 5

  Sources   Download

MIT

The Requires

 

by PovilasKorop
by KarolisNarkevicius

27/07 2017

0.1.0

0.1.0.0

API Generator for Laravel 5

  Sources   Download

MIT

The Requires

 

by PovilasKorop
by KarolisNarkevicius