PHPackages                             rebolon/api-json-param-converter - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. rebolon/api-json-param-converter

ActiveLibrary[HTTP &amp; Networking](/categories/http)

rebolon/api-json-param-converter
================================

A component to use with your project using ApiPlatform to allow easy custom routes creation.

v2.0.1(6y ago)58721[1 issues](https://github.com/Rebolon/ApiJsonParamConverterComponent/issues)[3 PRs](https://github.com/Rebolon/ApiJsonParamConverterComponent/pulls)MITPHPPHP ^7.3

Since Mar 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Rebolon/ApiJsonParamConverterComponent)[ Packagist](https://packagist.org/packages/rebolon/api-json-param-converter)[ RSS](/packages/rebolon-api-json-param-converter/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (13)Versions (19)Used By (0)

API Json ParamConverter for Symfony4
====================================

[](#api-json-paramconverter-for-symfony4)

[![Build Status](https://camo.githubusercontent.com/516cb86fc91a01901ad145292c0e4e1ccf9d500ab07cd4552b4a3df0dac91198/68747470733a2f2f7472617669732d63692e6f72672f5265626f6c6f6e2f4170694a736f6e506172616d436f6e766572746572436f6d706f6e656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Rebolon/php-sf-flex-webpack-encore-vuejs)[![FOSSA Status](https://camo.githubusercontent.com/b0ae971e33ecbf1f9b6d4872aeaad2bc9ceaf539e951e5512362091ff5297bc4/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532465265626f6c6f6e2532464170694a736f6e506172616d436f6e766572746572436f6d706f6e656e742e7376673f747970653d736869656c64)](https://app.fossa.io/projects/git%2Bgithub.com%2FRebolon%2FApiJsonParamConverterComponent?ref=badge_shield)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b5521f9fae161c96d42c8493d43365176bea83f2b8b0a2ee3016ebd0f8eaa38f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5265626f6c6f6e2f4170694a736f6e506172616d436f6e766572746572436f6d706f6e656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Rebolon/ApiJsonParamConverterComponent/badges/quality-score.png?b=master)[![Code Coverage](https://camo.githubusercontent.com/d69695098a8af2b14dfad350389af2ef3e9bd3589ee2b9201fb94c8b803ee340/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5265626f6c6f6e2f4170694a736f6e506172616d436f6e766572746572436f6d706f6e656e742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Rebolon/ApiJsonParamConverterComponent/?branch=master)[![Code Intelligence Status](https://camo.githubusercontent.com/c03efe670b65a578ba29a3731133ac0ccd929ac15e9c5d4379ffd8567d6b8a19/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5265626f6c6f6e2f4170694a736f6e506172616d436f6e766572746572436f6d706f6e656e742f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![FOSSA Status](https://camo.githubusercontent.com/b0ae971e33ecbf1f9b6d4872aeaad2bc9ceaf539e951e5512362091ff5297bc4/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532465265626f6c6f6e2532464170694a736f6e506172616d436f6e766572746572436f6d706f6e656e742e7376673f747970653d736869656c64)](https://app.fossa.io/projects/git%2Bgithub.com%2FRebolon%2FApiJsonParamConverterComponent?ref=badge_shield)

requirements
------------

[](#requirements)

You need PHP (7.x), composer, and Symfony 4

To get code coverage, don't forget that you need xDebug when you run PHPUnit or you will get this message: `Error:         No code coverage driver is available`If xDebug is not in the php configuration registered as your default php, you can run it manually:

```
PathToYouPHPWithXDebug vendor\phpunit\phpunit\phpunit

```

explanation
-----------

[](#explanation)

Working with ApiPlatform, i wanted to use custom POST route where i could send complex json data which represents nested entities. To realize this i choose to use the ParamConverters. So with little convention (json props must be the same as php entity props) and few ParamConverters (one per entity) extending the Rebolon/Request/ItemAbstractConverter (for one entity) or ListAbstractConverter (for collection of entities), it works !

Here are some samples of json sent to the custom routes:

```
// The most complete sample, with de-duplication of editor (only once will be created)
{
    "book": {
        "title": "Zombies in western culture",
        "editors": [{
            "publication_date": "1519664915",
            "collection": "printed version",
            "isbn": "9781783743230",
            "editor": {
                "name": "Open Book Publishers"
            }
        }, {
            "publication_date": "1519747464",
            "collection": "ebooks",
            "isbn": "9791036500824",
            "editor": {
                "name": "Open Book Publishers"
            }
        }],
        "authors": [{
            "role": {
                "translation_key": "WRITER"
            },
            "author": {
                "firstname": "Marc",
                "lastname": "O'Brien"
            }
        }, {
            "role": {
                "translation_key": "WRITER"
            },
            "author": {
                "firstname": "Paul",
                "lastname": "Kyprianou"
            }
        }],
        "serie": {
            "name": "Open Reports Series"
        }
    }
}

// This one re-use database information for editor / author / job / serie
{
    "book": {
        "title": "Oh my god, how simple it is !",
        "editors": [{
            "publication_date": "1519664915",
            "collection": "from my head",
            "isbn": "9781783742530",
            "editor": 1
        }, {
            "publication_date": "1519747464",
            "collection": "ebooks",
            "isbn": "9782821883963",
            "editor": {
                "name": "Open Book Publishers"
            }
        }],
        "authors": [{
            "role": 2,
            "author": 3
        }, {
            "role": {
                "translation_key": "WRITER"
            },
            "author": {
                "firstname": "Paul",
                "lastname": "Kyprianou"
            }
        }],
        "serie": {
            "id": 4,
            "name": "whatever because the paramConverte will only take care of the id property"
    }
}

```

The AbstractConverter is able to deduplicate entity (if there is more than one the same entity in the json). It's also able to retreive information from database if:

- you put ID instead of object inside the json (2nd sample above with editors\[0\].editor or authors\[0\].role)
- you send an object that contains the id field (or any other id prop name that you define in the specific Converter)

You can have a look at the tests to get more informations about how to use this component. I have wrote those test with sample Entities and Converter to make it more understandable.

configuration
-------------

[](#configuration)

Add all your ParamConverters in the config/services.yaml file, like this:

```
services:
    ...

    App\Request\ParamConverter\Library\BookConverter:
        public: true
        arguments:
            - '@validator'
        tags:
            - { name: request.param_converter, priority: -2, converter: book }

```

License
-------

[](#license)

[![FOSSA Status](https://camo.githubusercontent.com/f6e9c49ff3ce04f28625469562fd3f0df02e5750edba234b1e32a649df95eb20/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532465265626f6c6f6e2532464170694a736f6e506172616d436f6e766572746572436f6d706f6e656e742e7376673f747970653d6c61726765)](https://app.fossa.io/projects/git%2Bgithub.com%2FRebolon%2FApiJsonParamConverterComponent?ref=badge_large)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~59 days

Recently: every ~110 days

Total

13

Last Release

2265d ago

Major Versions

v1.3.4 → v2.0.02020-02-26

PHP version history (2 changes)v1.0.0PHP ^7.1

v2.0.0PHP ^7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/93af00da41678fc6e137333b3fe8caaeedbd931c0b4ac6166a2a36005bb263b2?d=identicon)[rebolon](/maintainers/rebolon)

---

Top Contributors

[![Rebolon](https://avatars.githubusercontent.com/u/1201755?v=4)](https://github.com/Rebolon "Rebolon (6 commits)")[![fossabot](https://avatars.githubusercontent.com/u/29791463?v=4)](https://github.com/fossabot "fossabot (1 commits)")

---

Tags

apiapiplatformphpsymfonyjsonapirest

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/rebolon-api-json-param-converter/health.svg)

```
[![Health](https://phpackages.com/badges/rebolon-api-json-param-converter/health.svg)](https://phpackages.com/packages/rebolon-api-json-param-converter)
```

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M236](/packages/api-platform-core)[api-platform/serializer

API Platform core Serializer

223.4M31](/packages/api-platform-serializer)[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)[api-platform/symfony

Symfony API Platform integration

323.2M67](/packages/api-platform-symfony)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[api-platform/validator

API Platform validator component

223.2M10](/packages/api-platform-validator)

PHPackages © 2026

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