New in Symfony 4.3: Native PHP Serialization for Messenger

Written by Symfony blog - - Aggregated on Friday March 15, 2019

Contributed by
Ryan Weaver
in #29958.

In Symfony 4.2, the Messenger component uses the Serializer component to serialize messages to JSON and then unserialize them. This creates some issues:

The original reason why we did this was so that we could export "generic JSON", in case we wanted other workers to consume the messages, no matter if they used Symfony, PHP or any other programming language and technology. However, this is not the common use case and it was complicating things unnecessarily.

In Symfony 4.3, we fixed this problem by switching the serialization to a new class called PhpSerializer which uses PHP's native serialize() and unserialize() to serialize messages to a transport.

If you want to keep using the previous JSON serializer (or your own custom serializer service) configure it as follows:

# config/packages/messenger.yaml
            # ID of the service to use to serialize messages
            id: 'messenger.transport.symfony_serializer'
Be trained by Symfony experts - 2019-04-1 Clichy - 2019-04-4 Clichy - 2019-04-8 Clichy

« Conferences are for making new friends - Cal Evans

Laracasts - Building the Layout »