sajad torkamani

In a nutshell

A normalizer is a class that converts PHP objects into PHP arrays and vice-versa. It implements the NormalizerInterface for normalizing (object to array), and the DenormalizerInterface for denormalizing (array to object).

What is a normalizer in Symfony Serializer?

You enable a normalizer in a serializer by passing it as the first argument:

use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;

$normalizers = [new ObjectNormalizer()];
$serializer = new Serializer($normalizers, []);

Built-in normalizers

The Symfony Serializer component provides several built-in normalizers.

Sources

Tagged: Symfony

Leave a comment

Your email address will not be published. Required fields are marked *