Download the PHP package rebolon/api-json-param-converter without Composer
On this page you can find all versions of the php package rebolon/api-json-param-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Rated 5.00 based on 1 reviews
Informations about the package api-json-param-converter
API Json ParamConverter for Symfony4
[![Build Status](https://travis-ci.org/Rebolon/ApiJsonParamConverterComponent.svg?branch=master)](https://travis-ci.org/Rebolon/php-sf-flex-webpack-encore-vuejs) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FRebolon%2FApiJsonParamConverterComponent.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FRebolon%2FApiJsonParamConverterComponent?ref=badge_shield) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Rebolon/ApiJsonParamConverterComponent/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Rebolon/ApiJsonParamConverterComponent/badges/quality-score.png?b=master) [![Code Coverage](https://scrutinizer-ci.com/g/Rebolon/ApiJsonParamConverterComponent/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Rebolon/ApiJsonParamConverterComponent/?branch=master) [![Code Intelligence Status](https://scrutinizer-ci.com/g/Rebolon/ApiJsonParamConverterComponent/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FRebolon%2FApiJsonParamConverterComponent.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FRebolon%2FApiJsonParamConverterComponent?ref=badge_shield)
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:
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 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
Add all your ParamConverters in the config/services.yaml file, like this:
License
All versions of api-json-param-converter with dependencies
api-platform/core Version ^2.5
doctrine/orm Version ^2.7
sensio/framework-extra-bundle Version ^5.5
squizlabs/php_codesniffer Version ^3.5
symfony/http-foundation Version ^5.0
symfony/property-access Version ^5.0
symfony/serializer Version ^5.0
symfony/validator Version ^5.0