sparq-php / event
Events made simple
1.0.4
2018-10-17 22:16 UTC
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: ^5
README
A simple to use event class. Add events to any class with a few lines of codes.
Installation and Autoloading
The recommended method of installing is via Composer.
Run the following command from your project root:
$ composer require sparq-php/event
Objectives
- Simple to use events
- Easy integration with other packages/frameworks
- Fast and low footprint
Usage
require_once __DIR__ . "/vendor/autoload.php";
use Sparq\Event\EventTrait;
class Foo
{
use EventTrait;
public function __construct()
{
$this->emit('eventName');
}
public function __set($key, $value)
{
$this->emit('set', [$key, $value]);
}
}
$Foo = new Foo();
$Foo->on('eventName', function() {
// do something
});