PHPackages                             xbld/laravel-api-response - 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. [API Development](/categories/api)
4. /
5. xbld/laravel-api-response

ActiveLibrary[API Development](/categories/api)

xbld/laravel-api-response
=========================

Response for restful API

1151PHP

Since Jul 1Pushed 10y ago1 watchersCompare

[ Source](https://github.com/XBLD/laravel-api-response)[ Packagist](https://packagist.org/packages/xbld/laravel-api-response)[ RSS](/packages/xbld-laravel-api-response/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel API Response
====================

[](#laravel-api-response)

### For Restful API's

[](#for-restful-apis)

Laravel does a great job formatting our responses into JSON and kicking them out appropriatly with application/json content types, but it does not help with any type of standard output format such as having a "status", or "messages" in the response. This class allows us to standardize all of our restful responses making our frontend friends much happier. Also helps with unit testing by having a true/false for each response.

Feature List:

- Standardized responses for all requests.
- Ability to log debug messages to response for easier debugging

##### Install

[](#install)

```
$ composer require xbld/laravel-api-response

```

##### Setup

[](#setup)

Open config\\app.php and add this to the providers array:

```
XBLD\ApiResponse\ApiResponseServiceProvider::class,

```

Dont forget to dump the autoload

```
$ composer dump-autoload

```

##### Usage

[](#usage)

This is intended to be used inside your controllers on a per method basis. Add the following to the top of your controller:

```
use XBLD\ApiResponse\APIResponse;

```

Example Method

```
public function store(Request $request)
{
	$return = new APIResponse();

    // If something fails on execution, Maybe a query does not
    // return anything...
    $return->status = false;
    $return->addMessage("Model Not Found");

    // Add the payload. Can be any array and will return JSON
    $return->payload = [
    	'foo'	=> 'bar',
        'bar'	=> true
    ];

    // Return the response.
    return $return->response();
}
```

Example Output:

```
{
	"status": false,
    "messages": [
    	"Model Not Found"
    ],
    "data": {
    	[
        	"foo": "bar",
            "bar": true
        ]
    },
    "completed_at": "2016-06-06 12:06:33"
}
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4360202?v=4)[Kaleb Clark](/maintainers/KalebClark)[@KalebClark](https://github.com/KalebClark)

---

Top Contributors

[![KalebClark](https://avatars.githubusercontent.com/u/4360202?v=4)](https://github.com/KalebClark "KalebClark (3 commits)")

### Embed Badge

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

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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