Simple Laravel package for creating API responses, compliant with JSend and the HTTP standard.
firebit/laravel-api-response is a Laravel package for simple laravel package for creating api responses, compliant with jsend and the http standard..
It currently has 3 GitHub stars and 197 downloads on Packagist (latest version 0.1.2.2).
Install it with composer require firebit/laravel-api-response.
Discover more Laravel packages by firebit
or browse all Laravel packages to compare alternatives.
Last updated
This package aims to makes responses from the API consistent and easy to use. It is compliant with the HTTP standard and the JSend standard.
function getUser($id){
// Get the data we wish to return
$user = User:find($id);
// If the user does not exist we return an error
if(!$user){
return ApiResponseFactory::notFound("User does not exist");
}
// Return the data by using a ReponseFactory
return ApiResponseFactory::success($user);
}
{
"status":"fail",
"message":"User does not exist"
}
{
"status":"success",
"data": {
"id":1,
"name":"John Doe",
"email":"[email protected]",
"created_at":null,
"updated_at":null
}
}
To install you can use Composer, use the following command to install this package.
composer require firebit/laravel-api-response
Coming soon!
For the license please check the LICENSE file, this project has the MIT license.