PHPackages                             4xxi/rest-request-errors - 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. 4xxi/rest-request-errors

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

4xxi/rest-request-errors
========================

Bundle providing serialization of REST request errors

1.4(6y ago)22.2k[1 issues](https://github.com/4xxi/rest-request-errors/issues)MITPHPPHP ^7.1.3

Since Apr 29Pushed 5y ago2 watchersCompare

[ Source](https://github.com/4xxi/rest-request-errors)[ Packagist](https://packagist.org/packages/4xxi/rest-request-errors)[ RSS](/packages/4xxi-rest-request-errors/feed)WikiDiscussions master Synced 6d ago

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

Request errors serialization bundle
===================================

[](#request-errors-serialization-bundle)

Bundle provides simple serialization for symfony form errors in JSON REST API.

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

[](#installation)

1. Install component via composer

```
composer require 4xxi/rest-request-errors
```

Usage
-----

[](#usage)

For Symfony forms:

```
use Fourxxi\RestRequestError\Exception\FormInvalidRequestException;

if (!$form->isValid()) {
    throw new FormInvalidRequestException($form);
}
```

For custom errors array:

```
use Fourxxi\RestRequestError\Exception\ArrayInvalidRequestException;

throw new ArrayInvalidRequestException([
    'field1' => 'errorValue',
    'field2' => 'someAnotherError'
]);
```

Examples above produces response:

```
{
  "errors": [

  ],
  "children": {
    "username": {
      "errors": [
        "Some error for form field"
      ],
      "children": []
    }
  }
}
```

If your application doesn't have exception listener, you can use bundle provided exception listener.

To enable it, add configuration yaml into `config/packages/rest_request_error.yaml` with following content:

```
rest_request_error:
  use_exception_listener: true
```

Decorating normalizer
---------------------

[](#decorating-normalizer)

If you want to modify errors response payload, you can decorate bundle normalizer with your own

Add to `services.yaml` decorate service

```
App\Serializer\CustomExceptionNormalizer:
    decorates: Fourxxi\RestRequestError\Serializer\InvalidRequestExceptionNormalizer
    arguments:
        - '@App\Serializer\CustomExceptionNormalizer.inner'
```

And create own decorator class:

```
final class CustomExceptionNormalizer implements NormalizerInterface
{
    /**
     * @var NormalizerInterface
     */
    private $normalizer;

    public function __construct(NormalizerInterface $normalizer)
    {
        $this->normalizer = $normalizer;
    }

    /**
     * @param InvalidRequestExceptionInterface $object
     */
    public function normalize($object, string $format = null, array $context = [])
    {
        $normalized = $this->normalizer->normalize($object, $format, $context);
        $normalized['code'] = $object->getStatusCode();

        return $normalized;
    }

    public function supportsNormalization($data, string $format = null)
    {
        return $this->normalizer->supportsNormalization($data, $format);
    }
}
```

Result:

```
{
  "errors": [],
  "children": {
    "test": {
      "errors": [
        "foo"
      ],
      "children": []
    }
  },
  "code": 400
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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 ~2 days

Total

4

Last Release

2202d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c15620e5ef34e199427dddde987be2aa0ba770ea54275bebd36c7b85d16b986a?d=identicon)[thirdparty@4xxi.com](/maintainers/thirdparty@4xxi.com)

---

Top Contributors

[![dbezmelnitsyn](https://avatars.githubusercontent.com/u/46677580?v=4)](https://github.com/dbezmelnitsyn "dbezmelnitsyn (5 commits)")

---

Tags

rest-apisymfony

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/4xxi-rest-request-errors/health.svg)

```
[![Health](https://phpackages.com/badges/4xxi-rest-request-errors/health.svg)](https://phpackages.com/packages/4xxi-rest-request-errors)
```

###  Alternatives

[sylius/sylius

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

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

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

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

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[sulu/headless-bundle

Bundle that provides controllers and services for using Sulu as headless content management system

55133.7k2](/packages/sulu-headless-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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