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

ActiveSymfony-bundle

1mcodes/api-problem-bundle
==========================

RFC7807 Problem details integration for Symfony

v0.2.0(3mo ago)08MITPHPPHP ~8.3.0 || ~8.4.0 || ~8.5.0

Since Jan 28Pushed 3mo agoCompare

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

READMEChangelog (1)Dependencies (11)Versions (5)Used By (0)

[![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

37

—

LowBetter than 83% of packages

Maintenance79

Regular maintenance activity

Popularity6

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.6% 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 ~0 days

Total

4

Last Release

110d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e20721348c977bdf1512ea38b591faa121dbdfc7839503882824f5600fd6d6e?d=identicon)[1mcodes](/maintainers/1mcodes)

---

Top Contributors

[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (40 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)")[![pottink](https://avatars.githubusercontent.com/u/2572887?v=4)](https://github.com/pottink "pottink (2 commits)")[![michaelgracious](https://avatars.githubusercontent.com/u/24290969?v=4)](https://github.com/michaelgracious "michaelgracious (2 commits)")[![tjveldhuizen](https://avatars.githubusercontent.com/u/779998?v=4)](https://github.com/tjveldhuizen "tjveldhuizen (2 commits)")[![neeckeloo](https://avatars.githubusercontent.com/u/1768645?v=4)](https://github.com/neeckeloo "neeckeloo (1 commits)")[![AnneSmids](https://avatars.githubusercontent.com/u/60921271?v=4)](https://github.com/AnneSmids "AnneSmids (1 commits)")[![1mcodes](https://avatars.githubusercontent.com/u/49844759?v=4)](https://github.com/1mcodes "1mcodes (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/1mcodes-api-problem-bundle/health.svg)

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

###  Alternatives

[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)

PHPackages © 2026

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