Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eliseekn/laravel-api-response
Send JSON response from your API.
https://github.com/eliseekn/laravel-api-response
Last synced: about 1 month ago
JSON representation
Send JSON response from your API.
- Host: GitHub
- URL: https://github.com/eliseekn/laravel-api-response
- Owner: eliseekn
- License: mit
- Created: 2023-12-14T12:04:28.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-05T05:40:22.000Z (10 months ago)
- Last Synced: 2024-10-12T00:54:23.220Z (3 months ago)
- Language: PHP
- Size: 56.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel API Response
[![Latest Version on Packagist](https://img.shields.io/packagist/v/eliseekn/laravel-api-response.svg?style=flat-square)](https://packagist.org/packages/eliseekn/laravel-api-response)
[![Total Downloads](https://img.shields.io/packagist/dt/eliseekn/laravel-api-response.svg?style=flat-square)](https://packagist.org/packages/eliseekn/laravel-api-response)Send JSON response from your API.
## Installation
```bash
composer require eliseekn/laravel-api-response
```## Usage
Add `MakeApiResponse` trait where you need to use and use it as follows :
```php
$this->response('success', 'Lorem ipsum dolor sit amet', 201);
$this->response('warning', [
'key1' => 'value',
'key2' => 'value'
], 405);$this->successResponse('Lorem ipsum dolor sit amet');
$this->successResponse([
'key1' => 'value',
'key2' => 'value'
]);$this->errorResponse(...);
```