Skip to content

lzyim/json-response

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

JSON-API response for Laravel

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages