Code Monkey home page Code Monkey logo

laravel-api-response-builder's Introduction

REST API Response Builder for Laravel

REST API Response Builder for Laravel

Latest Stable Version Build Status Code Quality Code Coverage Codacy Grade Badge Monthly Downloads License

SensioLabs Insight

Unstable Version Unstable Build Status Ustable Code Quality Unstble Code Coverage

Table of contents

Upgrading from previous version? Check compatibility docs prior altering your composer.json!


Introduction

ResponseBuilder is Laravel's helper designed to build nice, normalized and easy to consume REST API JSON responses.

Benefits

ResponseBuilder is written for REST API developers by REST API developer and is based on my long lasting experience on both "sides" (API dev and API consumer) of variety of REST APIs. Lightweight, with simple to use public methods, covering multiple potential use-cases, on-the-fly data conversion, localization support, automatic error message building, support for chained APIs and (hopefully) exhaustive documentation. But that's not all! The JSON structure produced by ResponseBuilder is designed with users of your API in mind, which helps them easily deal with your API with ease. They get simple, well defined and predictable JSON structure responses with all the fields needed to consume it without any unnecessary a hassle nor other trickery.

Android developers can use ApiResponse library to handle ResponseBuilder responses produced in their mobile applications.

You are even covered in case of emergency as provided Exception Handler ensures your API keeps talking JSON (and not HTML) to its clients if case of any unexpected and unhandled exception.

Did I mention, you also get testing traits that would automatically cover your whole ResponseBuilder related code with unit tests with just a few lines of code?

Usage examples

Operation successful? Conclude your controller method with:

return ResponseBuilder::success();

and your client will get nice JSON like

{
  "success": true,
  "code": 0,
  "locale": "en",
  "message": "OK",
  "data": null
}

Something went wrong? Just do:

return ResponseBuilder::error(250);

and the following JSON response will be returned

{
   "success": false,
   "code": 250,
   "locale": "en",
   "message": "Your error message for code 250",
   "data": null
}

Nice and easy! And yes, message can be easily customized! Also there're much, much more you can do with rich ResponseBuilder API. See library documentation for details and more examples!


Features


License

  • Written and copyrighted ©2016-2019 by Marcin Orlowski <mail (#) marcinorlowski (.) com>
  • ResponseBuilder is open-sourced software licensed under the MIT license

laravel-api-response-builder's People

Contributors

faridaghili avatar marcinorlowski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.