An open API service indexing awesome lists of open source software.

https://github.com/raviyatechnical/laravel-api-generator

Quickly generate api controller for your Laravel projects
https://github.com/raviyatechnical/laravel-api-generator

api api-auth api-authentication api-controller api-rest artisan cli generator laravel laravel-api-response laravel-api-response-helpers

Last synced: 20 days ago
JSON representation

Quickly generate api controller for your Laravel projects

Awesome Lists containing this project

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

- [@bhargavraviya](https://github.com/bhargavraviya)

## Support

For support, email raviyatechnical@gmail.com.

## 🔗 Links
[![portfolio](https://img.shields.io/badge/my_portfolio-000?style=for-the-badge&logo=ko-fi&logoColor=white)](https://raviyatechnical.medium.com)
[![linkedin](https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/company/raviyatechnical)
[![twitter](https://img.shields.io/badge/twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/raviyatechnical)

## License

[MIT](LICENSE)