PHPackages                             truegameover/laravel-api-response-builder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. truegameover/laravel-api-response-builder

ActiveLibrary[HTTP &amp; Networking](/categories/http)

truegameover/laravel-api-response-builder
=========================================

Helps building nice, normalized and easy to consume Laravel REST API.

1.0.4(5y ago)010MITPHPPHP &gt;=7.2.0

Since Sep 6Pushed 5y agoCompare

[ Source](https://github.com/TrueGameover/laravel-api-response-builder)[ Packagist](https://packagist.org/packages/truegameover/laravel-api-response-builder)[ Docs](https://github.com/TrueGameover/laravel-api-response-builder)[ RSS](/packages/truegameover-laravel-api-response-builder/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

[![REST API Response Builder for Laravel](docs/img/logo.png)](docs/img/logo.png)

REST API Response Builder for Laravel
=====================================

[](#rest-api-response-builder-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/56bd28ef3ee3f3c848584b9f2aa12054c94cb33f5884259eadaa9ff8067eeb40/68747470733a2f2f706f7365722e707567782e6f72672f6d617263696e2d6f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722f762f737461626c65)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)[![Build Status](https://camo.githubusercontent.com/a4ea2b2365f660d0e77caf1fffe0cf417254681d5532aa421c040692371956a2/68747470733a2f2f7472617669732d63692e6f72672f4d617263696e4f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/MarcinOrlowski/laravel-api-response-builder)[![Code Quality](https://camo.githubusercontent.com/2db9555d67c6fe1cd49a393ec5909891d9f4d58236b3a26e8ee96252192009ec/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d617263696e4f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/94d6f871c53203e00a677eafa9737db9dc2ae1364146e8a9765ee9d2b220354b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d617263696e4f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/?branch=master)[![Codacy Grade Badge](https://camo.githubusercontent.com/de7d1cedaa83ef244eb424d81a9ae5880ed598051593e87c5e3816369c71f34e/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3434663432376538373265323438303539376264653032343234313761326137)](https://www.codacy.com/app/MarcinOrlowski/laravel-api-response-builder)[![Monthly Downloads](https://camo.githubusercontent.com/f1e0f3ebf85f6998f75f615fa855e610606a6f784e09c8f02963ca48b2954318/68747470733a2f2f706f7365722e707567782e6f72672f6d617263696e2d6f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722f642f6d6f6e74686c79)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)[![License](https://camo.githubusercontent.com/4fd3b4b4e01429f78c346c3f12abce40e85de26c82ffde68087338f1cbc1849b/68747470733a2f2f706f7365722e707567782e6f72672f6d617263696e2d6f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722f6c6963656e7365)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)

[![SensioLabs Insight](https://camo.githubusercontent.com/bcf6906c4392e420abebb6d8c61c8e87ca3ee9571a2091c55350e7be97896351/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35633566346463312d343164352d343966392d623462612d3632363861613366656130302f6269672e706e67)](https://insight.sensiolabs.com/projects/5c5f4dc1-41d5-49f9-b4ba-6268aa3fea00)

[![Unstable Version](https://camo.githubusercontent.com/9810b3dc4c128aed5e8d40baabfed51b5befe0d844ee8bbd6f7e5cc2b1650d72/68747470733a2f2f706f7365722e707567782e6f72672f6d617263696e2d6f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722f762f756e737461626c65)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)[![Unstable Build Status](https://camo.githubusercontent.com/d95fd1d96da25fbfddb9c0197dcf622c0f55278398ddd64d207203b88f71627f/68747470733a2f2f7472617669732d63692e6f72672f4d617263696e4f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722e7376673f6272616e63683d646576)](https://travis-ci.org/MarcinOrlowski/laravel-api-response-builder)[![Ustable Code Quality](https://camo.githubusercontent.com/2f18c0518b0ca43daf32aea5220c54c9cee900685387b0e2db5d52abf7a21c9f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d617263696e4f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722f6261646765732f7175616c6974792d73636f72652e706e673f623d646576)](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/?branch=dev)[![Unstble Code Coverage](https://camo.githubusercontent.com/8036b0896cd85135b0c237eee929a064d4d90feb7e999cfe4844dcdef0811cb1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d617263696e4f726c6f77736b692f6c61726176656c2d6170692d726573706f6e73652d6275696c6465722f6261646765732f636f7665726167652e706e673f623d646576)](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/?branch=dev)

Table of contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Why should I use it?](#benefits)
- [Usage examples](#usage-examples)
- [Features](#features)
- [Documentation](docs/docs.md)
- [Requirements](docs/docs.md#requirements)
- [Installation and Configuration](docs/docs.md#installation-and-configuration)
- [Bugs reports and pull requests](CONTRIBUTING.md)
- [License](#license)
- [Changelog](CHANGES.md)

**Upgrading from previous version? Check [compatibility docs](docs/compatibility.md) prior altering your `composer.json`!**

---

Introduction
------------

[](#introduction)

`ResponseBuilder` is a [Laravel](https://laravel.com/) helper designed to build nice, normalized and easy to consume REST API JSON responses.

Benefits
--------

[](#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](https://github.com/MarcinOrlowski/ApiResponse) library to handle `ResponseBuilder`responses produced in their mobile applications.

You are even covered in a 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
--------------

[](#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 type:

```
return ResponseBuilder::error(250);

```

The following JSON response will then 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](docs/docs.md) for details and more examples!

---

Features
--------

[](#features)

- Easy to use,
- [Stable and production ready](https://travis-ci.org/MarcinOrlowski/laravel-api-response-builder),
- On-the-fly data object conversion,
- API chaining support,
- Localization support,
- Provides traits to help [unit test your API code](docs/testing.md),
- Comes with [exception handler helper](docs/exceptions.md) to ensure your API stays consumable even in case of unexpected,
- No additional dependencies.

---

License
-------

[](#license)

- Written and copyrighted ©2016-2020 by Marcin Orlowski &lt;mail (#) marcinorlowski (.) com&gt;
- ResponseBuilder is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

4

Last Release

2042d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8409946?v=4)[TrueGameover](/maintainers/TrueGameover)[@TrueGameover](https://github.com/TrueGameover)

---

Top Contributors

[![MarcinOrlowski](https://avatars.githubusercontent.com/u/8041294?v=4)](https://github.com/MarcinOrlowski "MarcinOrlowski (1019 commits)")[![TrueGameover](https://avatars.githubusercontent.com/u/8409946?v=4)](https://github.com/TrueGameover "TrueGameover (13 commits)")[![FaridAghili](https://avatars.githubusercontent.com/u/8607021?v=4)](https://github.com/FaridAghili "FaridAghili (1 commits)")

---

Tags

jsonapilaravelhelperrestbuilderPHP7

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/truegameover-laravel-api-response-builder/health.svg)

```
[![Health](https://phpackages.com/badges/truegameover-laravel-api-response-builder/health.svg)](https://phpackages.com/packages/truegameover-laravel-api-response-builder)
```

###  Alternatives

[marcin-orlowski/laravel-api-response-builder

Helps building nice, normalized and easy to consume Laravel REST API.

837458.6k3](/packages/marcin-orlowski-laravel-api-response-builder)[lomkit/laravel-rest-api

A package to build quick and robust rest api for the Laravel framework.

59152.2k](/packages/lomkit-laravel-rest-api)[givebutter/laravel-keyable

Add API keys to your Laravel models

187144.5k2](/packages/givebutter-laravel-keyable)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[guanguans/laravel-api-response

Normalize and standardize Laravel API response data structure. - 规范化和标准化 Laravel API 响应数据结构。

485.6k](/packages/guanguans-laravel-api-response)[bjerke/api-query-builder

A query builder for Laravel that parses the request and uses Eloquent ORM to query database

267.7k1](/packages/bjerke-api-query-builder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
