fyre/event

An event library.

v2.0.7 2024-06-25 04:06 UTC

This package is auto-updated.

Last update: 2024-06-25 04:06:46 UTC


README

FyreEvent

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);