https://github.com/lzyim/json-response
JSON-API response for Laravel
https://github.com/lzyim/json-response
json-response laravel
Last synced: 2 months ago
JSON representation
JSON-API response for Laravel
- Host: GitHub
- URL: https://github.com/lzyim/json-response
- Owner: lzyim
- Created: 2016-10-08T13:37:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-18T09:25:50.000Z (almost 9 years ago)
- Last Synced: 2025-12-14T06:25:16.551Z (6 months ago)
- Topics: json-response, laravel
- Language: PHP
- Size: 3.91 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Json Response
=====
Installation
------------
Install using composer:
```bash
composer require soloslee/json-response
```
Laravel (optional)
------------------
Add the service provider in `config/app.php`:
```php
'Soloslee\JsonResponse\JsonResponseServiceProvider::class',
```
And add the JsonResponse alias to `config/app.php`:
```php
'JsonResponse' => Soloslee\JsonResponse\Facades\JsonResponse::class,
```
Basic Usage
-----------
Start by creating an `JsonResponse` instance (or use the `JsonResponse` Facade if you are using Laravel):
```php
use Soloslee\JsonResponse\JsonResponse;
return JsonResponse::success();
```
### Success
```php
JsonResponse::success([
'id' => $user->id,
'phone' => $user->phone,
'email' => $user->email,
'authorized' => $user->cleaner,
'token' => $user->token
]);
```
### Error
```php
JsonResponse::error('Fails to send message.', 602);
```
## License
Laravel Json Response is licensed under [MIT license](http://opensource.org/licenses/MIT).