Closed Hefarius closed 6 years ago
If you want to use JMS serializer, you'll need to use version 0.2.0. There might be a away to override the serializer in the current version, but I'm not 100%.
ThruwayBundle switched to Symfony serializer a while ago (https://github.com/voryx/ThruwayBundle/commit/a0de46f647bd0ea62651c247ef53d4abe152c337). If you were counting on serialization groups provided by JMS in the controller annotations, I think the only way is to do the serialization yourself with JMS and return the results. At least, that's what I did.
It would be really great being able to make the choice about the used serializer on a per-project base. For my project it was impossible to stick to Symfony Serializer in conjunction with FOSRestBundle, but I like the approach how serialization is handled in FOSRestBundle, so this would be a really great feature cause I think many people are still using and continue to use JMS serializer. If I would use serialization handled properly with Thruway I have to annotate all entities twice, i.e. for JMS and Symfony serializer, which doesn't feel DRY.
But yes, the workaround proposed by @stingus will also work, even though it runs the normalization process twice, which doesn't feel optimal neither. So what do you think?
BTW: Thanks for the great library, integration into Symfony worked seamlessly 👍
Hi, @stingus, how do you manage to get the ClientManager instentiated with the Symfony Serializer ? As far as i request the service in any controller
$this->get('thruway.client')
JMS is passed as 3rd argument and symfony crashes ... Seems it's default behaviour cause I can't find anyplace in my project where I mention explicitly "always use JMS as serializer"... I use both JMS and FOSREST, maybe they're responsible of that ? I tried to declare them behind Thruway in my appKernel, but no effect. I can't find a way to go. If you get any clue, would be much appreciated ;) Thx. Btw, great work on that bundle! Same feelings that @arm1n 👍
The service configuration for thruway.client:
<service id="thruway.client"
class="Voryx\ThruwayBundle\Client\ClientManager" public="true">
<argument type="service" id="service_container"/>
<argument>%voryx_thruway%</argument>
<argument type="service" id="serializer"/>
</service>
As you can see, the 3rd argument is the service alias "serializer" which, with JMS 1.x in your project, will receive the JMS serializer and it will crash with a type error. You should switch to JMS 2.x, which removes the short alias "serializer" and uses "jms_serializer" instead (https://github.com/schmittjoh/JMSSerializerBundle/blob/7523f53d07fe659f789c51ad6f1cf3383d947200/UPGRADING.md). With this change, "serializer" alias will be the Symfony service and it'll work. When upgrading to JMS 2.x, take care of other services that are relying on the JMS serializer and change their service dependency alias to jms_serializer
.
Ho... I feel so ashamed :/ You just make me realized that we're running a so old version ... Gonna fix some others conflicts that we didn't see before too 👍 Great! Cheers. Boimb. [EDIT] So far, so good, updating JMS did the trick. I ran into an issue with the PawlTransportProvider dependency not being included in the requirements of ThruwayBundle 0.3.1 :
Attempted to load class "PawlTransportProvider" from namespace "Thruway\Transport". Did you forget a "use" statement for another namespace?
=> Added "thruway/pawl-transport": "0.5",
to my composer.json and problem solved.
I know you're aware of that... #77 ...But I thought I'could leave this here if other fellows get this error.
Once again, thx for that great Bundle and the support provided.
Keep up the good work 👍
[/EDIT]
Thank you. The issue was solved. Ticket can be closed.
Hello,
I have this error message after updating version : Type error: Argument 3 passed to Voryx\ThruwayBundle\Client\ClientManager::__construct() must be an instance of Symfony\Component\Serializer\Serializer, instance of JMS\Serializer\Serializer given
Can you have a solution for using JMS Serializer who allow group context and exclusion context ? All of our application coree use JMS serializer, it is very complicated to change
Ty
Greg