无法加载doctrine:config,services.xml

时间:2013-07-17 16:08:42

标签: symfony symfony-2.2

我正在尝试为我的项目构建一个eventlistener,并按照本指南的说明进行操作:How to register eventlisteners我在教程中编辑了我的services.xml,但是当我想测试它时,我收到此错误消息:

InvalidArgumentException: There is no extension able to load the configuration for "doctrine:config" (in /var/www/symfony/src/Acme/AppBundle/DependencyInjection/../Resources/config/services.xml). Looked for namespace "http://symfony.com/schema/dic/doctrine", found none

我的services.xml:

    <?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
    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">



    <doctrine:config>
        <doctrine:dbal default-connection="default">
            <doctrine:connection driver="pdo_sqlite" memory="true" />
        </doctrine:dbal>
    </doctrine:config>

    <services>
        <service id="my.listener" class="Acme\AppBundle\EventListener\Confirmer">
            <tag name="doctrine.event_listener" event="preUpdate" />
        </service>

    </services> 

</container>

问题出在哪里?

1 个答案:

答案 0 :(得分:1)

您不需要服务配置中的学说配置。

正在app/config/config.yml内配置连接驱动程序。 听众配置看起来不错 - 只需删除doctrine:config内容。

查看doctrine configuration reference

如果您未使用connection选项指定侦听器/订阅者,Symfony将自动使用默认连接。这里的文档有点令人困惑,但是学说连接就是为了展示如何使用不同的连接。