PHPackages                             tyler36/response-macro - 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. tyler36/response-macro

AbandonedArchivedLaravel-plugin[API Development](/categories/api)

tyler36/response-macro
======================

Standardizing JSON responses

1.1(7y ago)023PHPPHP &gt;=7.0

Since Jun 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/tyler36/response-macro)[ Packagist](https://packagist.org/packages/tyler36/response-macro)[ RSS](/packages/tyler36-response-macro/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Introduction
============

[](#introduction)

These macros help to standardize **api json response** returns throughout the application. Inspired by [Laravel Response Macros for APIs](https://blog.jadjoubran.io/2016/03/27/laravel-response-macros-api/)

Installation
------------

[](#installation)

- Install package

```
composer require tyler36/response-macro

```

### Success

[](#success)

Returns payload ($data) with an optional [HTTP status code](https://httpstatuses.com/) ($statusCode) \[Default: \[HTTP status code 200\]

```
response()->success($data);

```

EG.

```
response()->success(['earth' => 3, 'sun' => 'yellow'])

```

Returns **HTTP status 200** with the following:

```
{"errors":false,"data":{"earth":3,"sun":"yellow"}}

```

### noContent

[](#nocontent)

Returns empty content with a [HTTP status code 402](https://httpstatuses.com/204)

```
response()->noContent()

```

### Error

[](#error)

Returns message ($message) content with an optional [HTTP status code](https://httpstatuses.com/) ($statusCode) \[Default: [HTTP status code 400](https://httpstatuses.com/400)\]

```
response()->error($message);

```

Eg.

```
response()->error('There was an error.');

```

Returns **HTTP status 400** with the following:

```
{"errors":true,"message":"There was an error."}

```

Eg.

```
response()->error('Not authorized!', 403);

```

Returns **HTTP status 403** with the following:

```
{"errors":true,"message":"Not authorized!"}

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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.

###  Release Activity

Cadence

Every ~42 days

Total

2

Last Release

2851d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c68f48588d57835c170cde02444307a450b98cfab07c9674094b881545c13b76?d=identicon)[tyler36](/maintainers/tyler36)

---

Top Contributors

[![s-hendrix-iqnet](https://avatars.githubusercontent.com/u/180614482?v=4)](https://github.com/s-hendrix-iqnet "s-hendrix-iqnet (2 commits)")

---

Tags

apihelperlaravelresponselaravelservice provider

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/tyler36-response-macro/health.svg)

```
[![Health](https://phpackages.com/badges/tyler36-response-macro/health.svg)](https://phpackages.com/packages/tyler36-response-macro)
```

###  Alternatives

[obiefy/api-response

Simple Laravel package to return Json responses.

17324.6k](/packages/obiefy-api-response)[vinelab/api-manager

Laravel API Manager Package - beatify and unify your responses with the least effort possible.

392.1k](/packages/vinelab-api-manager)[dugajean/laravel-yaml

YAML parser for Laravel.

144.8k](/packages/dugajean-laravel-yaml)

PHPackages © 2026

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