PHPackages                             timezhero/laravel-rfc9457 - 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. timezhero/laravel-rfc9457

ActiveLibrary[API Development](/categories/api)

timezhero/laravel-rfc9457
=========================

RFC 9457 Problem Details for Laravel exceptions

v1.0.0(2mo ago)11PHP ^8.2

Since Apr 30Compare

[ Source](https://github.com/TimeZHero/laravel-rfc9457)[ Packagist](https://packagist.org/packages/timezhero/laravel-rfc9457)[ Docs](https://github.com/timezhero/laravel-rfc9457)[ RSS](/packages/timezhero-laravel-rfc9457/feed)WikiDiscussions Synced 3w ago

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

Laravel RFC 9457
================

[](#laravel-rfc-9457)

A Laravel package that standardizes API error responses using the [RFC 9457 Problem Details](https://www.rfc-editor.org/rfc/rfc9457) specification. Exceptions opt in via a trait and PHP attributes — no base class required, no HTTP coupling on your domain exceptions.

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

[](#installation)

```
composer require timezhero/laravel-rfc9457
```

The service provider is auto-discovered.

Quick start
-----------

[](#quick-start)

**1. Register the handler** in `bootstrap/app.php`:

```
use TimeZHero\Rfc9457\ProblemDetailsHandler;

return Application::configure(basePath: dirname(__DIR__))
    ->withExceptions(function (Exceptions $exceptions): void {
        ProblemDetailsHandler::register($exceptions);
    })
    ->create();
```

**2. Scaffold an exception:**

```
php artisan make:problem-exception InsufficientStock
```

**3. Throw it:**

```
throw new InsufficientStockException(productId: 42, requested: 30, available: 5);
```

Response (`409`, `application/problem+json`):

```
{
    "type": "/problems/insufficient-stock",
    "title": "Insufficient Stock",
    "detail": "The requested quantity of 30 exceeds the available stock of 5.",
    "status": 409,
    "instance": "/api/orders",
    "product_id": 42,
    "requested": 30,
    "available": 5
}
```

Validation errors, HTTP exceptions, and generic 5xx are also wrapped automatically.

CLI
---

[](#cli)

CommandWhat it does`php artisan make:problem-exception {name}`Creates exception class + translation entry + documentation view`php artisan vendor:publish --tag=rfc9457-config`Publish config`php artisan vendor:publish --tag=rfc9457-views`Publish views to customize the docs layoutAdvanced
--------

[](#advanced)

### Manual exception

[](#manual-exception)

```
#[Problem('Rate Limit Exceeded', Response::HTTP_TOO_MANY_REQUESTS)]
class RateLimitExceededException extends \RuntimeException
{
    use ProblemRfc9457;

    public function __construct(
        #[Extension(description: 'Seconds to wait before retrying.')]
        private readonly int $retryAfterSeconds,
    ) {
        parent::__construct('Internal log message');
    }

    protected function detail(): string
    {
        return __('exceptions.rate_limit_exceeded.detail', [
            'retry_after_seconds' => $this->retryAfterSeconds,
        ]);
    }
}
```

- `#[Problem]` — title + HTTP status. Type URI is derived from class name. Omit to auto-derive everything (defaults to 500)
- `#[Extension]` — marks properties as extension fields (snake\_cased in output). Use `name:` to override the key
- `detail()` — user-facing message (separate from internal `$message`). Return `''` to omit
- `extensions()` — override to add computed fields at runtime. Merged with attribute extensions

### Translations

[](#translations)

Convention-based in `lang/{locale}/exceptions.php`:

```
'insufficient_stock' => [
    'title' => 'Insufficient Stock',
    'detail' => 'Requested :requested but only :available available.',
],
```

Falls back to the raw `#[Problem]` title if no translation exists.

### Documentation pages

[](#documentation-pages)

Each exception gets a page at `/problems/{slug}`. Add a description view at `resources/views/vendor/rfc9457/details/{slug}.blade.php`. Extensions and metadata are rendered automatically.

### Configuration

[](#configuration)

```
// config/rfc9457.php
return [
    'exception_namespace' => 'App\\Exceptions',
    'documentation' => [
        'enabled' => true,       // set false to disable route + views entirely
        'route_prefix' => '/problems',
    ],
];
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance83

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

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

85d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/67009812?v=4)[Stefano Fasoli](/maintainers/TimeZHero)[@TimeZHero](https://github.com/TimeZHero)

---

Tags

apilaravelexceptionsproblem detailsrfc9457

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/timezhero-laravel-rfc9457/health.svg)

```
[![Health](https://phpackages.com/badges/timezhero-laravel-rfc9457/health.svg)](https://phpackages.com/packages/timezhero-laravel-rfc9457)
```

###  Alternatives

[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[illuminate/validation

The Illuminate Validation package.

18838.2M1.8k](/packages/illuminate-validation)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M246](/packages/laravel-ai)[illuminate/session

The Illuminate Session package.

9939.3M861](/packages/illuminate-session)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

813336.8k3](/packages/defstudio-telegraph)

PHPackages © 2026

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