PHPackages                             ogkarpf/respondr - 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. ogkarpf/respondr

ActiveLibrary[API Development](/categories/api)

ogkarpf/respondr
================

A Laravel package to standardize API responses.

1.0.0(9mo ago)01MITPHPPHP ^8.3

Since Sep 8Pushed 9mo agoCompare

[ Source](https://github.com/ogkarpf/respondr)[ Packagist](https://packagist.org/packages/ogkarpf/respondr)[ Docs](https://github.com/ogkarpf/respondr)[ RSS](/packages/ogkarpf-respondr/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (13)Versions (2)Used By (0)

Respondr
========

[](#respondr)

**Respondr** is a small Laravel package to standardize API responses. It ensures that all API responses are returned in a consistent format and provides helpful tools for error and success handling.

---

🚀 Installation
--------------

[](#-installation)

```
composer require ogkarpf/respondr
```

---

📦 Features
----------

[](#-features)

- Consistent JSON response structure for all API endpoints
- Facade for easy success and error responses
- Configurable response keys (`status`, `data`, `message`, `errors`)
- Optional middleware to automatically append an API version to every response

---

⚙️ Configuration
----------------

[](#️-configuration)

After installation, publish the config file:

```
php artisan vendor:publish --provider="ogkarpf\respondr\RespondrServiceProvider" --tag="respondr-config"
```

This will create `config/respondr.php` in your project.
You can customize the response keys, default status, and API version middleware:

```
return [
    'format' => [
        'status_key'  => 'status',
        'data_key'    => 'data',
        'message_key' => 'message',
        'errors_key'  => 'errors',
    ],
    'default_status' => 'success',
    'version_middleware' => [
        'enabled' => true,
        'version' => '1.0.0',
        'key' => 'api_version',
    ],
];
```

---

🧩 Usage
-------

[](#-usage)

### Success Response

[](#success-response)

```
use ogkarpf\respondr\Facades\Respondr;

return Respondr::success(['foo' => 'bar'], 'All good', 200);
```

### Error Response

[](#error-response)

```
// Pass error strings
return Respondr::error(['invalid_field'], 'Something went wrong', 422);

// Pass exceptions or throwables
return Respondr::error([new Exception('Custom error'), new RuntimeException('Runtime issue')], 'Failed', 400);
```

> **Note:**
> The `error` method accepts arrays containing strings, exceptions, or throwables.
> All throwable objects will be converted to their message text in the response.

---

🛡️ API Version Middleware
-------------------------

[](#️-api-version-middleware)

If enabled in the config, the middleware will automatically append the API version to every JSON response under the configured key (default: `api_version`).
The middleware is automatically applied to all routes in the `api` middleware group.

---

🧪 Testing
---------

[](#-testing)

You can run the included tests with:

```
composer test
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance55

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

298d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76554241?v=4)[Tim Brachschoss](/maintainers/ogkarpf)[@ogkarpf](https://github.com/ogkarpf)

---

Top Contributors

[![ogkarpf](https://avatars.githubusercontent.com/u/76554241?v=4)](https://github.com/ogkarpf "ogkarpf (11 commits)")

---

Tags

laravelogkarpfrespondr

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ogkarpf-respondr/health.svg)

```
[![Health](https://phpackages.com/badges/ogkarpf-respondr/health.svg)](https://phpackages.com/packages/ogkarpf-respondr)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.6k3](/packages/defstudio-telegraph)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)

PHPackages © 2026

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