Just a quick demo how to use Symfony Serializer
component.
Someone asked following on Symfony Slack workspace;
Hello, I've request body as following:
{ "name": "David", "siblings": [ { "name": "Brother's Name" } ] }
How do I make Serializer to serialize "siblings" as SiblingDto ? This array-of-object serialization is seem to not be working, can't find anything on symfony doc
So this repository contains simple example how to make that happen.
- You need to install
phpdocumentor/reflection-docblock
OR
- You need to implement "add" methods to your classes
OR
- Use
composer require symfony/serializer-pack
if you're using Symfony framework
IF you're using docblock annotations in your DTOs.
- Clone this repository
- Run
composer install
- Run
symfony serve
- Open shown URL with your browser
- Profit
Copyright © 2023 Tarmo Leppänen