mardi 20 février 2018

Why does laravel event listener require wildcards?

This works:

     Event::listen('Illuminate\Console\Events\ArtisanStartin*', function ($event, $data = []) {
         echo "event: $event\n";
     });

But this produces an error:

     Event::listen('Illuminate\Console\Events\ArtisanStarting', function ($event, $data = []) {
         echo "event: $event\n";
     });

Why is that? The first one outputs event: Illuminate\Console\Events\ArtisanStarting, the second one produces the error message Object of class Illuminate\Console\Events\ArtisanStarting could not be converted to string. The should both work the same way. Why is the wildcard required? Am I registering the event listener incorrectly?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire