FOSRestBundle: [BUG] Composer dependency is set improperly.
According to current documentation, the bundle needs a serializer and can either use JMSSerializerBundle or the Symfony Serializer
But if you have a look at the bundle code, it uses
Symfony\Component\Serializer\Normalizer\NormalizerInterface
now and then - thus meaning this bundle REQUIRES the Symfony Serializer
Steps to reproduce
- Create a new project with a Symfony utility. Along with other bundles, the FrameworkBundle is installed. This bundle has no Symfony Serializer installed by default.
- Try to install the FOSRestBundle.
- Get an error saying a serializer is required.
- Install JMSSerializerBundle. This bundle does not require Symfony Serializer. It only reqires FrameworkBundle, which, in turn, has no Symfony Serializer installed by default
Expectation: FOSRestBundle is now fully functional
Reality: FOSRestBundle is broken, because it heavily relies on Symfony\Component\Serializer
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (12 by maintainers)
okay, I see your point. thank you guys for being responsive.
I don’t think documenting internal classes is worth it, it would increase the work to maintain this bundle, it would make the docs less readable and only might be usefull to a small part of our users in my opinion.
These classes are marked as
@internal, if someone finds this class, I believe they can also find the@internalannotation. (And even if not, the symfony debug component will trigger a deprecation when extending such a class).About making them
final,@internalis more restrictive so no need imo.Well, you could do pretty much the same thing we do to extend the
FormErrorHandlerfrom the JMS serializer inFOS\RestBundle\Serializer\Normalizer\FormErrorHandler:FOS\RestBundle\Serializer\Normalizer\FormErrorHandlerto alter its output.The two serializers work differently, I don’t see the benefits of providing an abstraction over their normalizers/handlers, this would be complex (if even possible) for no gain. If you use the JMS Serializer, just use handlers, if you use the Symfony Serializer, use normalizers. That’s how things work in your project and adding a wrapper would even worsen DX in my opinion.
Composer doesn’t allow this. And anyway many libraries provide features that only work with suggested libraries (here it’s even just a library dependent implementation).
Honestly I don’t see the problem here, this class is not used by the bundle when the Symfony Serializer is not installed, you should do the same in your project.
Well, this class is precisely meant to be used with the Symfony Serializer component. If you use JMS Serializer instead, you will probably want to use the
FormErrorHandlerclass instead.