如何将symfony yaml配置文件转换为xml格式

时间:2022-05-06 11:13:42

I'd like to hold symfony config and routing files as xml files. I know, there are many code examples in the symfony-book but not all configurations-types are shown.

我想将symfony配置和路由文件作为xml文件。我知道,symfony-book中有很多代码示例,但并未显示所有配置类型。

Is there any way to convert the existing yaml-files given from the symfony demo project to xml files to use these files as a base?

有没有办法将symfony演示项目中给出的现有yaml文件转换为xml文件,以便将这些文件用作基础?

I found a dumper class in '/Symfony/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php' but I don't know if this tool is useful for my problem, never mind how to use it.

我在'/Symfony/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php'中找到了一个转储类,但我不知道这个工具是否对我的问题有用,更不用说如何使用它了。

So, has anyone an idea about it?

那么,有人对此有所了解吗?

Please excuse my weird english, I'm from Germany ... and I hope that this fact won't reduce my chances of getting an answer :-)

请原谅我奇怪的英语,我来自德国......我希望这个事实不会减少我得到答案的机会:-)

3 个解决方案

#1


1  

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:

据我所知,Symfony中没有通用的Yaml-to-XML转储器。我在2009年底发现了Fabien博客的评论:

Fabien — December 21, 2009 10:38 #3

Fabien - 2009年12月21日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.

@simo:你可以创建一个从XML到YAML的通用转换器,反之亦然,因为语义是完全不同的。在symfony中,我们同时支持YAML和XML,但转换是针对每个功能手工制作的。

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 *.

但是,许多第三方软件包(包括大多数FriendsOfSymfony软件包)都选择使用XML作为其配置格式。您可以浏览github上的代码以获取示例,或者如果您有特定的转换问题,可以将其带到*。

#2


8  

You can do automatic conversion between YAML / INI / XML with the third party Symfony2 Service Config Converter.

您可以使用第三方Symfony2服务配置转换器在YAML / INI / XML之间进行自动转换。

#3


1  

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

Symfony2软件包(2.4.0)包含其AcmeDemoBundle的yml类型文件。更改现有的yml文件是一件麻烦事。但是,您可以进行一些修改,使新创建的包使用xml格式配置和路由。您可以修改/app/config/config.yml

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

Also, /app/config/routing_dev.yml

另外,/ app / config /routing_dev.yml

# resource: routing.yml
resource: routing.xml

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

通过执行这些更改,您可以在构建自己的包时选择使用xml。

#1


1  

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:

据我所知,Symfony中没有通用的Yaml-to-XML转储器。我在2009年底发现了Fabien博客的评论:

Fabien — December 21, 2009 10:38 #3

Fabien - 2009年12月21日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.

@simo:你可以创建一个从XML到YAML的通用转换器,反之亦然,因为语义是完全不同的。在symfony中,我们同时支持YAML和XML,但转换是针对每个功能手工制作的。

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 *.

但是,许多第三方软件包(包括大多数FriendsOfSymfony软件包)都选择使用XML作为其配置格式。您可以浏览github上的代码以获取示例,或者如果您有特定的转换问题,可以将其带到*。

#2


8  

You can do automatic conversion between YAML / INI / XML with the third party Symfony2 Service Config Converter.

您可以使用第三方Symfony2服务配置转换器在YAML / INI / XML之间进行自动转换。

#3


1  

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

Symfony2软件包(2.4.0)包含其AcmeDemoBundle的yml类型文件。更改现有的yml文件是一件麻烦事。但是,您可以进行一些修改,使新创建的包使用xml格式配置和路由。您可以修改/app/config/config.yml

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

Also, /app/config/routing_dev.yml

另外,/ app / config /routing_dev.yml

# resource: routing.yml
resource: routing.xml

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

通过执行这些更改,您可以在构建自己的包时选择使用xml。