v1.0.2 2022-11-28 11:55 UTC

This package is auto-updated.

Last update: 2023-09-28 13:46:56 UTC


Events allow you to insert custom code into existing code at specific points in execution. You can attach custom code to an event so that when the event fires, the code is automatically executed.


composer require shancept/event


first case

  1. create event class implements EventInterface. Example.
  2. create event handler class. Example.
  3. call trigger event at the right place Event::trigger(new Event()).
  4. subscribe to the event before executing it Event::listen(SomeClass::class, static function ($event) {}).

second case

  1. use trait in your class.
  2. record all events via EventTrait::recordEvent.
  3. call in the right place: EventBus::dispatch().
  4. pass EventTrait::releaseEvents result to the "dispatch" function parameter.