Symfony Restful Post: JMSSerializerBundle vs Symfony Form Components Symfony Restful Post: JMSSerializerBundle vs Symfony Form Components symfony symfony

Symfony Restful Post: JMSSerializerBundle vs Symfony Form Components


In our restfull API we usually use the Symfony Serializer component to handle the deserialization of entities, then the Symfony Validator component to ensure that the entities fulfill all the required conditions before pushing/updating them in database. Works pretty well, lighter than the form component.

Anyway The Form component would not be able to deserialize the json/xml so you'll have to use a serializer.


The benefit of the Symfony\Form component over the JMS Serializer is that the validation is done before deserialization which fits into PHP 7 strict typing. Example case - you pass an array instead of a string, JMS creates and object and the getter raises a \TypeError instead of a validation error from the validator.