Skip to content
Advertisement

Have no idea why the listener is not being called in Laravel

Heres the event:

JavaScript

The event gets called just fine. But the listener:

JavaScript

Never gets called. Ever. So how am I registering these?

JavaScript

I have never had an issue registering events and listeners like this before. They always work. But for some reason the listener will not fire for this event. The event fires just fine. But not the listener. What am I missing?

I have tried:

  • php artisan optimize
  • composer dump-autoload

Nothing.

Its called as such:

JavaScript

Any ideas? I checked spelling and namespaces and everything seems correct. What am I missing?

There are no errors, nothing. The tests still pass (I dont fake events) and the test coverage shows the event gets called, but the test coverage shows the listener does not get called. When I try this out in the browser, no user is created – which is done by the listener.

All my other events and their associated listeners are called just fine.

What is going on?

Advertisement

Answer

So I am retarded and will take the downvotes on this one but for future reference, make sure your use statements are proper. because Laravel won’t tell you when registering events:

JavaScript

What do you think is missing here? let me tell you:

JavaScript

This is why the event was being called but not the listener. In the controller class where the event in question was being called, I imported the event properly, but in the event service provider I did not.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement