gpt4 book ai didi

symfony - 打包后如何使用 xml 而不是 yml

转载 作者:行者123 更新时间:2023-12-02 22:00:33 24 4
gpt4 key购买 nike

Mybundle 已经设置为使用 services.yml

但是我想用services.xml。

所以我在 DependacyInjection/MybundleExtension.php 中进行了更改

#$loader->load('services.yml');     
$loader->load('services.xml');

但是它说

Unable to parse in      "\/Users\/whitebear\/httproot\/mutor\/src\/Acme\/MyBundle\/DependencyInjection\/..\/Resources\/config\/services.xml" at line 1 (near "").

我的 services.xml 在这里,我认为它是正确的(只是从其他站点复制和粘贴)

<services>
<service id="acme.demobundle.calendar_listener" class="Acme\DemoBundle\EventListener\CalendarEventListener">
<argument type="service" id="doctrine.orm.entity_manager" />
<tag name="kernel.event_listener" event="calendar.load_events" method="loadEvents" />
</service>

</services>

还有什么地方需要修改吗?

最佳答案

你使用XmlFileLoader吗?

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');

标准的 xml 结构包括 container 标签

<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
...
</parameters>

<services>
<service id="...">
</service>
</services>
</container>

关于symfony - 打包后如何使用 xml 而不是 yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17016654/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com