fyre / event
An event library.
v2.0.9
2024-10-17 13:29 UTC
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- fyre/php-cs-fixer-config: ^1.0
- phpunit/phpunit: ^10
README
FyreEvent is a free, open-source events library for PHP.
Table Of Contents
Installation
Using Composer
composer require fyre/event
In PHP:
use Fyre\Event\Event;
Methods
Clear
Clear all events.
Event::clear();
Has
Check if an event exists.
$name
is a string representing the event name.
$hasEvent = Event::has($name);
Off
Remove event(s).
$name
is a string representing the event name.$callback
is the callback to remove.
$removed = Event::off($name, $callback);
If the $callback
argument is omitted, all events will be removed instead.
Event::off($name);
On
Add an event.
$name
is a string representing the event name.$callback
is the callback to execute.$priority
is a number representing the callback priority, and will default to Event::PRIORITY_NORMAL.
Event::on($name, $callback, $priority);
Trigger
Trigger an event.
$name
is a string representing the event name.
Any additional arguments supplied will be passed to the event callback.
Event::trigger($name, ...$args);