Download the PHP package phasty/events without Composer
On this page you can find all versions of the php package phasty/events. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download phasty/events
More information about phasty/events
Files in phasty/events
Download phasty/events
More information about phasty/events
Files in phasty/events
Please rate this library. Is it a good library?
Informations about the package events
Events
Package supplies support of event handling on different kind of objects. To use this you just inherite your class from Phasty\Events\Eventable or use Phasty\Events\EventableTrait trait within you class:
class SomeCoolClass extends Phasty\Events\Eventable {
}
$obj = new SomeCoolClass;
$obj->on("hello-event", function($event) {
echo $event->getData();
});
$obj->trigger("hello-event", "Hello world");
Output:
Hellow world!
And more:
class Button extends Phasty\Events\Eventable {
public function __construct() {
$this->on("click", "sayHello");
$this->on("click", "sayGoodbye");
}
protected function sayHello() {
echo "Hello!\n";
}
protected function sayGoodbye() {
echo "Bye!\n";
}
public function click() {
$this->trigger("before-click");
$this->trigger("click");
}
}
$btn = new Button;
$btn->on("before-click", function () {
echo "Before click handler\n";
});
$btn->click();
$btn->off("click", "sayHello");
$btn->click();
Output:
Before click handler
Hello!
Bye!
Before click handler
Bye!
USAGE
// Listen to some-event
$obj->on("some-event", /* Any PHP callback or method name of $obj class */);
// Listen to any event
$obj->on(null, /* Any PHP callback or method name of $obj class */);
// Forget all events callbacks
$obj->off();
// Forget all callbacks of "some-event" event
$obj->off("some-event");
// Forget exact callback for "some-event"
$obj->off("some-event", /* Any PHP callback or method name of $obj class */);
All versions of events with dependencies
PHP Build Version
Package Version
Requires
phasty/log Version
>=0.1
The package phasty/events contains the following files
Loading the files please wait ....