Skip to content

Latest commit

 

History

History
38 lines (35 loc) · 1.12 KB

README.md

File metadata and controls

38 lines (35 loc) · 1.12 KB

Laravel API Response Wrapper

If you get tired of rewriting your JSON structure in every response, this package could be something you need. I believe that rewriting every JSON structure manually could lead to inconsistent JSON structures and be hard to maintain. If somehow we want to change the JSON response format, we have to change it in every location.

What this package does?

This package can help you simplify the way you create a JSON response by using its facade accessor like ApiResponseWrapper::get("", $data), and the output will be something like:

HTTP OK 200
{
  "success": true,
  "message": "",
  "data": {...}
}

Installation

composer require silverhand7/laravel-api-response-wrapper

Available Response

get

ApiResponseWrapper::get($message, $data)
Params type
$message ?string
$data array|Collection

created

ApiResponseWrapper::created($message, $data)
Params type
$message ?string
$data array|Collection