Symfony 4 "Expected to find class" error happens randomly

  symfony, symfony4

I have a listener called LoginListener which works, but for some reason randomly i get this error when making a request for a route. If i then refresh it doesn’t happen, then will randomly happen again.

Expected to find class "AppSecurityLoginListener" in file
"/home/nibbrstaging/webuyanyhouse.nibbrstaging.com/api/src/Security/LoginListener.php"
while importing services from resource "../src/*", but it was not
found! Check the namespace prefix used with the resource in
/home/nibbrstaging/webuyanyhouse.nibbrstaging.com/api/config/services.yaml
(which is loaded in resource
"/home/nibbrstaging/webuyanyhouse.nibbrstaging.com/api/config/services.yaml").

I’ve noticed this a few times when i say edit a controller and add a new route, it will then throw this error. If i then come in and delete a bunch of white space in the new controller method it goes away.

It’s a strange issue this, has anyone seen this happen before and how to solve it?

Source: Symfony Questions

LEAVE A COMMENT