How to convert symfony yaml config files to xml format? How to convert symfony yaml config files to xml format? symfony symfony

How to convert symfony yaml config files to xml format?


As far as I know, there is no generic Yaml-to-XML dumper in Symfony. I found this comment from Fabien's blog back at the end of 2009:

Fabien — December 21, 2009 10:38 #3

@simo: You can have create a generic converter from XML to YAML or vice-versa, because the semantics are quite different. In symfony, we support both YAML and XML, but the conversion is hand-crafted for each feature.

However, many 3rd-party bundles (including most of the FriendsOfSymfony bundles) have chosen to use XML as their configuration format. You can browse through code on github for examples, or if you have a specific conversion question, you can bring it here to StackOverflow.


The Symfony2 package (2.4.0) contains yml type files for their AcmeDemoBundle. It is a hassle to change those existing yml files. However, you can make a little modifications that make your newly created bundles use xml format config and routing. You can modify /app/config/config.yml

# resource: "%kernel.root_dir%/config/routing.yml"resource: "%kernel.root_dir%/config/routing.xml"

Also, /app/config/routing_dev.yml

# resource: routing.ymlresource: routing.xml

By doing these changes, you can choose to use xml when you build your own bundles.


more a comment like an answer because it doesn't solve the real question (convert from yaml to xml) but the comment space was too small and to unformated for this info and as it is currently state of the art to use php configs instead of yaml or xml it might be accepted from the stackoverflow community as a helpful.

so the current solution would be to use migrify/config-transformer https://github.com/migrify/config-transformer

vendor/bin/config-transformer switch-format app/config --input-format xml --output-format yaml

How to Switch from YAML/XML Configs to PHP Today with Migrify
https://tomasvotruba.com/blog/2020/07/27/how-to-switch-from-yaml-xml-configs-to-php-today-with-migrify/

10 Cool Features You Get after switching from YAML to PHP Configs
https://tomasvotruba.com/blog/2020/07/16/10-cool-features-you-get-after-switching-from-yaml-to-php-configs/