Quickly generate rest api for your projects! with API Response Helpers
Require the Laravel Repository Generator with composer.
composer require raviyatechnical/laravel-api-generator:dev-master --dev
For usage take the following steps. Generate the api controller and base controller.
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');
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
Run the following command.
php artisan api:controller UserController
This example will generate the following files:
App\Http\Controllers\API\UserController
Server: Laravel API
For support, email raviyatechnical@gmail.com.