This kind of makes the MyEvent class redundant, as it is not instantiated, and the $object is passed directly into the handler, rather than the event itself.
What ? Elaborate please.
It is always the event object which is passed to the handler.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all, I've been creating some events, in particular subscribing events to listeners, and to fire the event i've been using the helper function event.
I noticed though that this function can take two arguments eventname and payload, as an alternative to simply calling event(new MyEvent($object)).
This kind of makes the MyEvent class redundant, as it is not instantiated, and the $object is passed directly into the handler, rather than the event itself.
Is there any pros and cons to doing it this way?
Please or to participate in this conversation.