Search code examples
phpsymfonydeserializationserializationsymfony-components

Symfony serializer doesn't work with --no-dev


I'm using symfony serializer. But if I install composer packages with --no-dev flag, it deserializes data that supposed to be array of objects in array of arrays instead.

This is serialization:

$result = $this->get('serializer')->deserialize(
    $request->getContent(),
    InputDto::class,
    'json'
);

And for deserialization I use annotations in DTO.

This is how "field" looks in DTO for objects array:

/**
 * @var OrderItemDto[]|Collection
 */
private $items = [];

Solution

  • To make object sublevel work you need to add to app/config/config.yml in framework section next lines:

    property_info:
        enabled: true