soloslee / json-response by solo

JSON-API response for Laravel
91
8
1
Package Data
Maintainer Username: solo
Maintainer Contact: ssoloim@gmail.com (solo)
Package Create Date: 2016-10-08
Package Last Update: 2017-06-18
Language: PHP
License: MIT
Last Refreshed: 2024-11-11 15:01:35
Package Statistics
Total Downloads: 91
Monthly Downloads: 2
Daily Downloads: 1
Total Stars: 8
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Json Response

Installation

Install using composer:

composer require soloslee/json-response

Laravel (optional)

Add the service provider in config/app.php:

'Soloslee\JsonResponse\JsonResponseServiceProvider::class',

And add the JsonResponse alias to config/app.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):

use Soloslee\JsonResponse\JsonResponse;

return JsonResponse::success();

Success

JsonResponse::success([
    'id' => $user->id,
    'phone' => $user->phone,
    'email' => $user->email,
    'authorized' => $user->cleaner,
    'token' => $user->token
]);

Error

JsonResponse::error('Fails to send message.', 602);

License

Laravel Json Response is licensed under MIT license.