In Laravel 11, you can still register multiple listeners for a single event, but the syntax is slightly different from what you've shown in your last code snippet. You can use the Event::listen method multiple times for the same event, as you've already discovered. However, if you want to register multiple listeners at once, you can use a loop or an array map. Here's an example of how you can do it:
foreach ([FirstEventListener::class, SecondEventListener::class] as $listener) {
Event::listen(EventName::class, $listener);
}
Alternatively, you can use array_map to achieve the same result:
array_map(function ($listener) {
Event::listen(EventName::class, $listener);
}, [FirstEventListener::class, SecondEventListener::class]);
Both of these methods will register each listener for the EventName::class event. This is essentially the same as calling Event::listen multiple times, but it's a bit cleaner, especially if you have a large number of listeners.
As of my knowledge cutoff date, there isn't a built-in method in Laravel 11 to pass an array of listeners directly to the Event::listen method as you've shown in your last code snippet. You would need to iterate over the listeners in some way, as shown above.