Symfony Listener gone missing after minor changes in Controller

I am encountering some weir behaviour with Symfony listener. I have a working configuration, but when I change or add something to the controller, Expected to find class "AppEventListenerAuthenticationSuccessListener" shows up. The change could be only something inside route path string. All code is here.
Remove cache and server restart doesn’t help.


namespace AppBundleEventListener;

use LexikBundleJWTAuthenticationBundleEventAuthenticationSuccessEvent;
use LexikBundleJWTAuthenticationBundleEventAuthenticationFailureEvent;
use LexikBundleJWTAuthenticationBundleResponseJWTAuthenticationFailureResponse;
use SymfonyComponentSerializerSerializerInterface;

class AuthenticationListener
     * @var SerializerInterface
    private $serializer;

    public function __construct(SerializerInterface $serializer)
        $this->serializer = $serializer;

     * @param AuthenticationSuccessEvent $event
    public function onAuthenticationSuccessResponse(AuthenticationSuccessEvent $event)

            'user' => $this->serializer->normalize($event->getUser(), null, ['groups' => ['basic']]),
            'token' => $event->getData()['token'],




# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed

        class: AppBundleEventListenerAuthenticationListener
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_success, method: onAuthenticationSuccessResponse }
    # default configuration for services in *this* file
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
        resource: '../src/*'
        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

    # controllers are imported separately to make sure services can be injected
    # as action arguments even if you don't extend any base controller class
        resource: '../src/Controller'
        tags: ['controller.service_arguments']



namespace AppController;

use AppEntityUser;
use DoctrineORMEntityManager;
use DoctrineORMEntityManagerInterface;
use SensioBundleFrameworkExtraBundleConfigurationIsGranted;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationJsonResponse;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentRoutingAnnotationRoute;
use SymfonyComponentSerializerSerializerInterface;

class ApiUserController extends AbstractController
     * @Route("/api/verify_token", methods="POST", name="api_verify_token")
     * @IsGranted("ROLE_USER")
    public function verifyToken(User $user = null){
        return new JsonResponse([], 200);


Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *