Symfony - Unable to load a listener service

424 views Asked by At

I'm trying to load a listener but symfony keeps throwing this error:

ClassNotFoundException in appDevDebugProjectContainer.php line 1783:

Attempted to load class "CommandeListener" from namespace "Louvre\ReversationBundle\Services\Listeners". 
Did you forget a "use" statement for another namespace?

My class is properly writen (i guess):

<?php

namespace Louvre\ReservationBundle\Services\Listeners;

use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;

class CommandeListener {


    public function checkCommand(FilterResponseEvent $event){
       if (!$event->isMasterRequest() && $event->getRequest()->get('_route') == "louvre_reservation_step1") {
           return;
        }
        $url = $this->router->generate("louvre_reservation_step1");
        $response = new RedirectResponse($url);
        $event->setResponse($response);

    }
}

Its path is

src/Louvre/ReservationBundle/Services/Listeners/CommandeListener.php

and here is the yaml service

louvre_reservation.commande.listener:
    class: Louvre\ReversationBundle\Services\Listeners\CommandeListener
    tags:
        - { name: kernel.event_listener, event: kernel.request, method: checkCommande }

I have other services which work perfectly. they are declared the same way.

I googled the problem but could not find an answer.

Does anyone already faced this problem? Thanks in advance

1

There are 1 answers

0
Marc-André On

It looks like you made a typo in your class include. You wrote "Reversation" instead of "Reservation" which make your code looks into the "Reversation" folder which does not exists.