Question

I am trying to build an eventlistener for my project and followed the instruction of this guide: How to register eventlisteners I edited my services.xml like in the tutorial , but i get this error message, when i want to test it:

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

My 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>

Where is the problem?

Was it helpful?

Solution

You don't need the doctrine configuration in your service config.

The connection driver is being configured inside app/config/config.yml. The listener configuration looks good though - just remove the doctrine:config stuff.

Have a look at the doctrine configuration reference.

Symfony will automatically use the default connection for your listener/subscriber if you don't specify one using the connectionoption. The documentation is a bit confusing here but the doctrine connection is just there to show how to use a different connection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top