rami/problem-detail-bundle

A Symfony bundle that implements application/problem+json to give meaning to api response errors

Installs: 381

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/rami/problem-detail-bundle

v1.1.2 2026-01-07 11:08 UTC

This package is auto-updated.

Last update: 2026-01-07 11:09:27 UTC


README

RFC 9457: Problem Details for HTTP API deprecated by RFC 9457

Implementation of the RFC 9457 to give meaning to HTTP Response Errors

A simple bundle

Composer installation:

composer require rami/problem-detail-bundle

example use:

use Symfony\Component\HttpFoundation\Response;
use Rami\ProblemDetailBundle\ProblemResponse\ProblemJsonResponse;
use Symfony\Component\HttpFoundation\JsonResponse;

class ArticleController 
{

    public function addArticle(): Response 
    {
        ... 
        if (false === $user->canPostArticle()) {
            return new ProblemJsonResponse(Response::HTTP_FORBIDDEN, title: "Insufficient permission", detail: "You have insufficient permission to add a new article");
        }
        ...
        
        return new JsonResponse(['status' => 'created', 'id' => $article->getId()]);
    }
}

This will return an application/problem+json response

{
  "type": "about:blank",
  "title": "Insufficient permission",
  "status": 404,
  "detail": "You have insufficient permission to add a new article"
}