2017 © Pedro Peláez
 

library rest-api-generators

Laravel REST API scaffolding.

image

tmphp/rest-api-generators

Laravel REST API scaffolding.

  • Thursday, June 29, 2017
  • by YanDatsyuk
  • Repository
  • 3 Watchers
  • 6 Stars
  • 98 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 12 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

Codacy Badge License, (*1)

Laravel REST API Generator

Code scaffolding for REST API project by database schema. This package is available also on packagist. And installation via packagist is preferred way., (*2)

Examples

There are two open source REST API projects on GitHub, developed using this generator: * Social network * Appartment rentals, (*3)

Installation

Package installation

  • add "tmphp/rest-api-generators": "dev-master" to your composer.json (node "require")
  • set "minimum-stability": "dev" in your composer.json
  • run composer update

Configuration

Open your config/app.php and add this line in providers section, (*4)

TMPHP\RestApiGenerators\GeneratorsServiceProviders::class,
Dingo\Api\Provider\LaravelServiceProvider::class,
Way\Generators\GeneratorsServiceProvider::class,
Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class,
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
L5Swagger\L5SwaggerServiceProvider::class,
Abhijitghogre\LaravelDbClearCommand\LaravelDbClearCommandServiceProvider::class,
Felixkiss\UniqueWithValidator\ServiceProvider::class,

Publishing configuration files

Execute command, (*5)

php artisan vendor:publish

Open your config/jwt.php and change line with a user's model namespace., (*6)

'user' => 'App\REST\User',

Configurating .env file

  • set proper connection to the database
  • add configuration for dingo/api package. See detailed docs here
  • required configuration string is API_DOMAIN=yourdomain.dev

Register middleware

Add middleware to App/Http/Kernel.php to the $routeMiddleware array., (*7)

'check.role.access' => \TMPHP\RestApiGenerators\Middleware\CheckAccess::class,

Swagger configuration

Add '/routes' path in 'config/l5-swagger.php', annotation path., (*8)

'annotations' => [base_path('app'), base_path('routes')],

Database schema

Make sure, that you have created database schema. For generating relations you should have FOREIGN KEY Constraints., (*9)

Generating code for REST API project

  • Run artisan command for code scaffolding.
php artisan make:rest-api-project
  • Generate swagger documentation.
php artisan l5-swagger:generate
  • Execute command
composer dump-autoload
  • :elephant: :boom: :+1: :+1:

The Versions

12/06 2017

dev-bugfix/not_all_scopes_are_deleting_on_removing_duplicates

dev-bugfix/not_all_scopes_are_deleting_on_removing_duplicates

Laravel REST API scaffolding.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yan Datsyuk
by Alex Storojenko