symfonyjmsserializerbundlejms-serializer

JMS Serializer: overriding default naming strategy in symfony 4 has no effect


I found this thread proposing a neat way of overriding globally the default naming strategy in config.yml

but this is for symfony 3 and I am on symfony 4 so I added the line to my config > packages > jms_serializer.yaml but this has no effect at all.

jms_serializer:
  visitors:
    xml_serialization:
        format_output: '%kernel.debug%'
  property_naming:
    id: 'jms_serializer.identical_property_naming_strategy'

Does anyone understand why ?

I do dependency injection of SerializerInterface $serializer to use the serializer as it is not possible to call the service from AbstractController in SF4. Controller is deprecated in SF4.


Solution

  • Try removing var/cache manually. When I cleared cache with cache:clear command it didn't work, but after I cleaned it manually it did!

    I hope this solution will help you too.