PHPackages                             phpro/api-problem-bundle - 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. phpro/api-problem-bundle

ActiveSymfony-bundle[API Development](/categories/api)

phpro/api-problem-bundle
========================

RFC7807 Problem details integration for Symfony

1.12.1(3mo ago)25533.1k—8.6%12[2 issues](https://github.com/phpro/api-problem-bundle/issues)2MITPHPPHP ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Aug 31Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/phpro/api-problem-bundle)[ Packagist](https://packagist.org/packages/phpro/api-problem-bundle)[ RSS](/packages/phpro-api-problem-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (20)Used By (2)

[![Installs](https://camo.githubusercontent.com/f349abaf9b6ca4d9f8fde1fb616f8fcc9cd892c9c6fb072a4f7a007aadcaf876/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706870726f2f6170692d70726f626c656d2d62756e646c652e737667)](https://packagist.org/packages/phpro/api-problem-bundle/stats)[![Packagist](https://camo.githubusercontent.com/85097124d6cf9f9ed918b44202b0ff91a07af8a87fb40008835a7954590df688/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870726f2f6170692d70726f626c656d2d62756e646c652e737667)](https://packagist.org/packages/phpro/api-problem-bundle)

Api Problem Bundle
==================

[](#api-problem-bundle)

This package provides a [RFC7807](https://tools.ietf.org/html/rfc7807) Problem details exception listener for Symfony. Internal, this package uses the models provided by [`phpro/api-problem`](https://www.github.com/phpro/api-problem). When an `ApiProblemException` is triggered, this bundle will return the correct response.

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

[](#installation)

```
composer require phpro/api-problem-bundle
```

If you are not using `symfony/flex`, you'll have to manually add the bundle to your bundles file:

```
// config/bundles.php

return [
    // ...
    Phpro\ApiProblemBundle\ApiProblemBundle::class => ['all' => true],
];
```

Supported response formats
--------------------------

[](#supported-response-formats)

- application/problem+json

How it works
------------

[](#how-it-works)

```
use Phpro\ApiProblem\Exception\ApiProblemException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class SomeController
{
    /**
     * @Route('/some-route', defaults={"_format" = "json"})
     */
    public function someAction() {
        throw new ApiProblemException(
            new HttpApiProblem('400', 'It aint all bad ...')
        );
    }
}
```

When the controller is marked as a "json" format, the request `Content-Type` is `*/json` or the request `Accept` header first value contains json (i.e. `application/json, text/html`), this bundle kicks in. It will transform the exception to following response:

Headers:

```
Content-Type: application/problem+json

```

Body:

```
{
    "status": 400,
    "type": "http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html",
    "title": "Bad Request",
    "detail": "It ain't all bad ..."
}
```

As an alternative, use `ApiProblemHttpException` instead of `ApiProblemException`, to make it possible to [exclude the specific status code from the log](https://symfony.com/doc/current/logging/monolog_exclude_http_codes.html)

Adding custom exception transformations
---------------------------------------

[](#adding-custom-exception-transformations)

Currently, we automatically transform exceptions from following packages to an ApiProblem instance:

- phpro/api-problem
- symfony/http-kernel
- symfony/security

Besides that, all other errors are transformed to a basic `ExceptionApiProblem` instance.

If you want to add custom transformations, you can implement the `ExceptionTransformerInterface`and register it in the symfony container with the `phpro.api_problem.exception_transformer` tag.

```
use Phpro\ApiProblemBundle\Transformer\ExceptionTransformerInterface;

class MyTransformer implements ExceptionTransformerInterface
{
    public function transform(\Throwable $exception): ApiProblemInterface
    {
        return new MyApiProblem($exception);
    }

    public function accepts(\Throwable $exception): bool
    {
        return $exception instanceof MyException;
    }
}
```

About
-----

[](#about)

### Submitting bugs and feature requests

[](#submitting-bugs-and-feature-requests)

Bugs and feature request are tracked on [GitHub](https://github.com/phpro/api-problem-bundle/issues). Please take a look at our rules before [contributing your code](CONTRIBUTING).

### License

[](#license)

api-problem-bundle is licensed under the [MIT License](LICENSE).

###  Health Score

65

—

FairBetter than 99% of packages

Maintenance80

Actively maintained with recent releases

Popularity48

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 63.8% 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 ~170 days

Recently: every ~109 days

Total

17

Last Release

95d ago

PHP version history (6 changes)v1.0.0PHP ^7.2

v1.3.0PHP ^7.3 || ^8.0

v1.4.0PHP ^8.0

1.6.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

1.10.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

1.11.0PHP ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

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

---

Top Contributors

[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (44 commits)")[![andrew-demb](https://avatars.githubusercontent.com/u/12499813?v=4)](https://github.com/andrew-demb "andrew-demb (9 commits)")[![filippeb](https://avatars.githubusercontent.com/u/4455858?v=4)](https://github.com/filippeb "filippeb (6 commits)")[![michaelgracious](https://avatars.githubusercontent.com/u/24290969?v=4)](https://github.com/michaelgracious "michaelgracious (2 commits)")[![pottink](https://avatars.githubusercontent.com/u/2572887?v=4)](https://github.com/pottink "pottink (2 commits)")[![tjveldhuizen](https://avatars.githubusercontent.com/u/779998?v=4)](https://github.com/tjveldhuizen "tjveldhuizen (2 commits)")[![AnneSmids](https://avatars.githubusercontent.com/u/60921271?v=4)](https://github.com/AnneSmids "AnneSmids (1 commits)")[![neeckeloo](https://avatars.githubusercontent.com/u/1768645?v=4)](https://github.com/neeckeloo "neeckeloo (1 commits)")[![sitepark-veltrup](https://avatars.githubusercontent.com/u/92872893?v=4)](https://github.com/sitepark-veltrup "sitepark-veltrup (1 commits)")[![tdutrion](https://avatars.githubusercontent.com/u/1712222?v=4)](https://github.com/tdutrion "tdutrion (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpro-api-problem-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/phpro-api-problem-bundle/health.svg)](https://phpackages.com/packages/phpro-api-problem-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[freshcells/soap-client-bundle

SoapClientBundle for symfony

35151.0k](/packages/freshcells-soap-client-bundle)

PHPackages © 2026

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