https://github.com/tarlepp/symfony-serializer-example
https://github.com/tarlepp/symfony-serializer-example
community-help example serializer symfony
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tarlepp/symfony-serializer-example
- Owner: tarlepp
- License: mit
- Created: 2023-08-28T14:23:24.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-28T15:08:10.000Z (over 2 years ago)
- Last Synced: 2024-04-09T21:52:34.443Z (almost 2 years ago)
- Topics: community-help, example, serializer, symfony
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# What is this?
Just a quick demo how to use Symfony `Serializer` component.
## Question
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.
## TL;DR
* 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.
## Installation
1. Clone this repository
2. Run `composer install`
3. Run `symfony serve`
4. Open shown URL with your browser
5. Profit
## Authors
* [Tarmo Leppänen](https://github.com/tarlepp)
## License
[The MIT License (MIT)](LICENSE)
Copyright © 2023 Tarmo Leppänen