New in Symfony 4.3: Native PHP Serialization for Messenger
- The default serializer requires you to have getter & setter methods (or public properties) for them to be serialized. This makes it easy for data to disappear.
- Moreover, the forced getters/setters (and no required constructor arguments) force you to design your message classes around this.
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
PhpSerializer which uses PHP's native
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:
1 2 3 4 5 6
# config/packages/messenger.yaml framework: messenger: serializer: # ID of the service to use to serialize messages id: 'messenger.transport.symfony_serializer'
New in Symfony 4.3: Native PHP Serialization for Messenger symfony.com/blog/new-in-symfony-4-3-native-php-serialization-for-messengerTweet this