8000 Messenger - support for JMS serializer · Issue #28756 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Messenger - support for JMS serializer #28756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
r3m4k3 opened this issue Oct 7, 2018 · 8 comments
Closed

Messenger - support for JMS serializer #28756

r3m4k3 opened this issue Oct 7, 2018 · 8 comments

Comments

@r3m4k3
Copy link
r3m4k3 commented Oct 7, 2018

Hi there!

I use a new component messenger but unfortunately, I got still more and more errors about serialization. Symfony serializer has problems with array collections, interfaces and even nested objects.
In my whole project, I use JMS serializer and there are no problems, for this, I need to use Symfony serializer.
How can I fix this or maybe set as a default serializer JMS in messenger component, is it possible?

I'm struggling with normalization, de- and serialization for almost 2 days, IMO Symfony serializer is one of the weakest components, it's almost unusable when sb got used to JMS and its convenience.

@r3m4k3 r3m4k3 changed the title Messenger circular reference with entities Messenger - support for JMS serializer Oct 7, 2018
@dunglas
Copy link
Member
dunglas commented Oct 8, 2018

Symfony serializer has problems with array collections

https://symfony.com/doc/current/components/serializer.html#handling-arrays

interfaces

https://symfony.com/doc/current/components/serializer.html#serializing-interfaces-and-abstract-classes

even nested objects

https://symfony.com/doc/current/components/serializer.html#recursive-denormalization-and-type-safety

Be sure to use the symfony/serializer-pack to get all required dependencies, and to enable the PropertyInfo component (until a new release containing #28735 is tagged).

@jewome62
Copy link
Contributor
jewome62 commented Oct 8, 2018

If you want use another serializer, you can implement this interface with JMSSerializer if you want ?

@sroze
Copy link
Contributor
sroze commented Oct 21, 2018

As @jewome62 mentioned, you can already do it by implementing this interface and set the framework.messenger.serializer configuration.

@sroze sroze closed this as completed Oct 21, 2018
@sroze
Copy link
Contributor
sroze commented Oct 21, 2018

I'd recommend using Symfony Serializer though :)

@webdevilopers
Copy link
webdevilopers commented May 13, 2019

@jewome62 You can also use this adapter by @kunicmarko20 :
https://github.com/kunicmarko20/jms-messenger-adapter

If you are using Hateoas PHP you will have to add some changes to composer to get it working:

        "jms/serializer": "2.3.0",
        "kunicmarko/jms-messenger-adapter": "^0.1.1",
        "ocramius/proxy-manager": "2.1.0",
        "willdurand/hateoas": "3.0",
        "willdurand/hateoas-bundle": "2.0.0"

@webdevilopers
Copy link

I'd recommend using Symfony Serializer though :)

I would love to use it. Unfortunately it requires your serialized class to have a getter prefixes with "get" or public properties. Our DTOs have only private properties and getters never have the "get" prefix. :/

@spolischook
Copy link
Contributor
Unfortunately it requires your serialized class to have a getter prefixes with "get" or public properties.

I have fixed this by configuration using native_php_serializer:

 framework:
     messenger:
         serializer:
-            default_serializer: messenger.transport.symfony_serializer
+            default_serializer: messenger.transport.native_php_serializer

@webdevilopers
Copy link

That's great new @spolischook , thank you.

I will test the serializer in our next project and give you feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
0