PHPackages                             jenky/api-error-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. jenky/api-error-bundle

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

jenky/api-error-bundle
======================

A bundle that formats the JSON api problem

0.3.1(5mo ago)078MITPHPPHP ^8.1CI passing

Since Mar 4Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/jenky/api-error-bundle)[ Packagist](https://packagist.org/packages/jenky/api-error-bundle)[ Docs](https://github.com/jenky/api-error-bundle)[ RSS](/packages/jenky-api-error-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

A Symfony bundle that formats the JSON api problem
==================================================

[](#a-symfony-bundle-that-formats-the-json-api-problem)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b8eaa02406984028b4631cf5117b5140e984e62d1c35ec593a80e355656c156f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a656e6b792f6170692d6572726f722d62756e646c652e7376673f6c6f676f3d7061636b6167697374267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/jenky/api-error-bundle)[![Github Actions](https://camo.githubusercontent.com/1a855d09baf153c0e5ce31541e162fda94eef73f1006d8c8b075ea29927e58f3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a656e6b792f6170692d6572726f722d62756e646c652f74657374696e672e796d6c3f6272616e63683d6d61696e266c6162656c3d616374696f6e73266c6f676f3d676974687562267374796c653d666f722d7468652d6261646765)](https://github.com/jenky/api-error-bundle)[![Codecov](https://camo.githubusercontent.com/e7ef29b7ce23c03b015ecfe3a84afc8fe694c7d449a353fe02cf97d5565a8dfa/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6a656e6b792f6170692d6572726f722d62756e646c653f6c6f676f3d636f6465636f76267374796c653d666f722d7468652d6261646765)](https://codecov.io/gh/jenky/api-error-bundle)[![Total Downloads](https://camo.githubusercontent.com/4f0f1aef7643bb3affff5747a1154a81fc3760252b971d5de611659afcd35fbe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a656e6b792f6170692d6572726f722d62756e646c652e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/jenky/api-error-bundle)[![Software License](https://camo.githubusercontent.com/9897f4467850972a38c7db9a4d38280b8fcdac0ada00e9c8c0a72ecfa8551653/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666f722d7468652d6261646765)](LICENSE.md)

Standardize error responses in your Symfony application using [RFC7807](https://datatracker.ietf.org/doc/html/rfc7807) Problem details or any custom error format.

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

[](#installation)

You can install the package via composer:

```
composer require jenky/api-error-bundle-bunder
```

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

```
// config/bundles.php

return [
    // ...
    Jenky\Bundle\ApiError\ApiErrorBundle::class => ['all' => true],
];
```

Configuration
-------------

[](#configuration)

### Generic Error Response Format

[](#generic-error-response-format)

By default all thrown exceptions will be transformed into the following format:

```
{
    'message' => '{message}', // The exception message
    'status' => '{status_code}', // The corresponding HTTP status code, defaults to 500
    'code' => '{code}' // The exception int code
    'debug' => '{debug}', // The debug information
}
```

> The debug information only available when application debug mode (`kernel.debug`) is on.

Example:

```
curl --location --request GET 'http://myapp.test/api/not-found' \
--header 'Accept: application/json'
```

```
{
  "message": "Not Found",
  "status": 404,
  "code": 0,
}
```

### RFC7807 Problem details

[](#rfc7807-problem-details)

You will need to create an alias from `Jenky\ApiError\Formatter\ErrorFormatter` interface to `api_error.error_formatter.rfc7807`.

```
# config/services.yaml

services:
    # ...
    Jenky\ApiError\Formatter\ErrorFormatter: '@api_error.error_formatter.rfc7807'
```

> For more information, please visit [https://symfony.com/doc/current/service\_container/autowiring.html#dealing-with-multiple-implementations-of-the-same-type](https://symfony.com/doc/current/service_container/autowiring.html#dealing-with-multiple-implementations-of-the-same-type).

### Custom Error Format

[](#custom-error-format)

Create your own custom formatter that implements [`ErrorFormatter`](https://github.com/jenky/api-error/blob/main/src/Formatter/ErrorFormatter.php). Alternatively, you can extend the [`AbstractErrorFormatter`](https://github.com/jenky/api-error/blob/main/src/Formatter/AbstractErrorFormatter.php), provided for the sake of convenience, and define your own error format in the `getFormat` method.

Register your service if needed, in case `autowire` and `autoconfigure` are disabled. Then create the alias:

```
# config/services.yaml

services:
    # ...
    api_error.error_formatter.custom:
        class: MyCustomErrorFormatter
        #

    Jenky\ApiError\Formatter\ErrorFormatter: '@api_error.error_formatter.custom'
```

Alternatively, you can use the `GenericErrorFormatter` and [configure `ErrorFormatter` service with a Configurator](https://symfony.com/doc/current/service_container/configurators.html):

```
# services.yaml

services:
    #

    Jenky\ApiError\Formatter\ErrorFormatter:
        parent: Jenky\ApiError\Formatter\AbstractErrorFormatter
        class: Jenky\ApiError\Formatter\GenericErrorFormatter
        configurator: '@App\ApiError\ErrorFormatterConfigurator'
```

```
// App\ApiError\ErrorFormatterConfigurator.php

use Jenky\ApiError\Formatter\GenericErrorFormatter;

final class ErrorFormatterConfigurator
{
    public function __invoke(GenericErrorFormatter $formatter): void
    {
        $formatter->setFormat([
            'message' => '{title}',
            'status' => '{status_code}',
            'code' => '{code}',
            'errors' => '{errors}',
        ]);
    }
}
```

### [Exception Transformations](https://github.com/jenky/api-error?tab=readme-ov-file#exception-transformations)

[](#exception-transformations)

If you want to add custom transformations, you should create a new class that implements the [`ExceptionTransformer`](ExceptionTransformer). With `autoconfigured` **enabled**, you're all set. Otherwise, register it in Symfony container with the `api_error.exception_transformer` tag.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Lynh](https://github.com/jenky)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance73

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

Every ~95 days

Total

4

Last Release

153d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/783e915bb411d566e8f1035f197842db5e870a2a995b3943bcbe5db2f9abf09b?d=identicon)[Milano](/maintainers/Milano)

---

Top Contributors

[![jenky](https://avatars.githubusercontent.com/u/1808758?v=4)](https://github.com/jenky "jenky (25 commits)")

---

Tags

api-problemapi-errorapi-problem-bundleapi-error-bundle

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jenky-api-error-bundle/health.svg)

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

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23914.2M16](/packages/hubspot-api-client)[lstrojny/fxmlrpc

Fast and tiny XML/RPC client with bridges for various HTTP clients

1425.4M30](/packages/lstrojny-fxmlrpc)

PHPackages © 2026

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