项目作者: lizhiyong6

项目描述 :
JSON-API response for Laravel
高级语言: PHP
项目地址: git://github.com/lizhiyong6/json-response.git
创建时间: 2016-10-08T13:37:06Z
项目社区:https://github.com/lizhiyong6/json-response

开源协议:

下载


Json Response

Installation

Install using composer:

  1. composer require soloslee/json-response

Laravel (optional)

Add the service provider in config/app.php:

  1. 'Soloslee\JsonResponse\JsonResponseServiceProvider::class',

And add the JsonResponse alias to config/app.php:

  1. 'JsonResponse' => Soloslee\JsonResponse\Facades\JsonResponse::class,

Basic Usage

Start by creating an JsonResponse instance (or use the JsonResponse Facade if you are using Laravel):

  1. use Soloslee\JsonResponse\JsonResponse;
  2. return JsonResponse::success();

Success

  1. JsonResponse::success([
  2. 'id' => $user->id,
  3. 'phone' => $user->phone,
  4. 'email' => $user->email,
  5. 'authorized' => $user->cleaner,
  6. 'token' => $user->token
  7. ]);

Error

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

License

Laravel Json Response is licensed under MIT license.