raviyatechnical/laravel-api-generator

Generate Laravel API

dev-master 2023-08-12 10:06 UTC

This package is auto-updated.

Last update: 2024-04-12 11:43:28 UTC


README


Logo

Laravel API Generator

Quickly generate rest api for your projects! with API Response Helpers



Installation

Require the Laravel Repository Generator with composer.

composer require raviyatechnical/laravel-api-generator:dev-master --dev

Usage

For usage take the following steps. Generate the api controller and base controller.

Generating BaseController With Auth (Laravel Sanctum)

WARNING make you sure that file not exits it is overwrite file

Run the following command.

php artisan api:install --auth

This will generate the following files:

App\Http\Controllers\API\BaseController
App\Http\Controllers\API\Auth\LoginController.php
App\Http\Controllers\API\Auth\RegisterController.php
App\Http\Resources\AuthResource.php

Add Route On This Path: routes/web.php

use App\Http\Controllers\API\Auth\LoginController;
use App\Http\Controllers\API\Auth\RegisterController;
...
Route::post('register', [RegisterController::class, 'register'])->name('auth.register');
Route::post('login', [LoginController::class, 'login'])->name('auth.login');
Route::post('logout', [LoginController::class, 'logout'])->name('auth.logout')->middleware('auth:sanctum');
Route::post('logout-all', [LoginController::class, 'logoutAll'])->name('auth.logout.all')->middleware('auth:sanctum');

Generating BaseController Without Auth

WARNING make you sure that file not exits it is overwrite file

Run the following command.

php artisan api:install

This will generate the following files:

App\Http\Controllers\API\BaseController

Generating API Controller

Run the following command.

php artisan api:controller UserController

This example will generate the following files:

App\Http\Controllers\API\UserController

Tech Stack

Server: Laravel API

Authors

Support

For support, email raviyatechnical@gmail.com.

🔗 Links

portfolio linkedin twitter

License

MIT