PHPackages                             offspring/laravel-handle-responder - 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. offspring/laravel-handle-responder

ActiveLibrary[API Development](/categories/api)

offspring/laravel-handle-responder
==================================

A Laravel package for building API responses

2.8(6y ago)09.1k—7.8%MITPHPPHP &gt;=5.5.9

Since Sep 4Pushed 6y ago1 watchersCompare

[ Source](https://github.com/boyfigure/laravel-handle-responder)[ Packagist](https://packagist.org/packages/offspring/laravel-handle-responder)[ RSS](/packages/offspring-laravel-handle-responder/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (15)Used By (0)

Laravel Responder is a package for building API responses,

Installation
============

[](#installation)

To get started, install the package through Composer:

```
composer require offspring/laravel-handle-responder
```

#### Publish Package Assets *(optional)*

[](#publish-package-assets-optional)

You may additionally publish the package configuration and language file using the `vendor:publish` Artisan command:

```
php artisan vendor:publish --provider="Offspring\Responder\ResponderServiceProvider"
```

This will publish a `responder.php` configuration file in your `config` folder. It will also publish an `errors.php` file inside your `lang/en` folder which can be used for storing error messages.

```

####  Use `responder` Helper

If you're a fan of Laravel's `response` helper function, you may like the `responder` helper function:

```php
return responder()->success();

```

```
return responder()->error();
```

### Building Responses

[](#building-responses)

The `success` and `error` methods return a `SuccessResponseBuilder` and `ErrorResponseBuilder` respectively, which both extend an abstract `ResponseBuilder`, giving them common behaviors. They will be converted to JSON when returned from a controller, but you can explicitly create an instance of `Illuminate\Http\JsonResponse` with the `respond` method:

```
return responder()->success()->respond();
```

```
return responder()->error()->respond();
```

The status code is set to `200` by default, but can be changed by setting the first parameter. You can also pass a list of headers as the second argument:

```
return responder()->success()->respond(201, ['x-foo' => true]);
```

```
return responder()->error()->respond(404, ['x-foo' => false]);
```

---

*Consider always using the `respond` method for consistency's sake.*

---

### Casting Response Data

[](#casting-response-data)

Instead of converting the response to a `JsonResponse` using the `respond` method, you can cast the response data to a few other types, like an array:

```
return responder()->success()->toArray();
```

```
return responder()->error()->toArray();
```

### Decorating Response

[](#decorating-response)

A response decorator allows for last minute changes to the response before it's returned. The package comes with two response decorators out of the box adding a `status` and `success` field to the response output. The `decorators` key in the configuration file defines a list of all enabled response decorators:

```
'decorators' => [
    \Offspring\Responder\Http\Responses\Decorators\StatusCodeDecorator::class,
    \Offspring\Responder\Http\Responses\Decorators\SuccessFlagDecorator::class,
],
```

You may disable a decorator by removing it from the list, or add your own decorator extending the abstract class `Flugg\Responder\Http\Responses\Decorators\ResponseDecorator`. You can also add additional decorators per response:

```
return responder()->success()->decorator(ExampleDecorator::class)->respond();
```

```
return responder()->error()->decorator(ExampleDecorator::class)->respond();
```

---

The package also ships with some situational decorators disabled by default, but which can be added to the decorator list:

- `PrettyPrintDecorator` decorator will beautify the JSON output;

```
\Offspring\Responder\Http\Responses\Decorators\PrettyPrintDecorator::class,
```

- `EscapeHtmlDecorator` decorator, based on the "sanitize input, escape output" concept, will escape HTML entities in all strings returned by your API. You can securely store input data "as is" (even malicious HTML tags) being sure that it will be outputted as un-harmful strings. Note that, using this decorator, printing data as text will result in the wrong representation and you must print it as HTML to retrieve the original value.

```
\Offspring\Responder\Http\Responses\Decorators\EscapeHtmlDecorator::class,
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 96% 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 ~15 days

Recently: every ~50 days

Total

14

Last Release

2292d ago

Major Versions

0.3 → 1.02019-09-05

1.0 → 2.02019-09-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/238abd30949663be2fade0c342583cd520f4d6a22fcf1e114d74659f210582d7?d=identicon)[boyfigure](/maintainers/boyfigure)

---

Top Contributors

[![tonyoffs](https://avatars.githubusercontent.com/u/47514640?v=4)](https://github.com/tonyoffs "tonyoffs (24 commits)")[![boyfigure](https://avatars.githubusercontent.com/u/7472855?v=4)](https://github.com/boyfigure "boyfigure (1 commits)")

---

Tags

apilaravelresponder

### Embed Badge

![Health badge](/badges/offspring-laravel-handle-responder/health.svg)

```
[![Health](https://phpackages.com/badges/offspring-laravel-handle-responder/health.svg)](https://phpackages.com/packages/offspring-laravel-handle-responder)
```

###  Alternatives

[flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

8911.6M5](/packages/flugger-laravel-responder)

PHPackages © 2026

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