1. Go to this page and download the library: Download romeoz/rock-events library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
romeoz / rock-events example snippets
use rock\events\Event;
class Foo
{
public $str = 'Rock!';
}
$object = new Foo();
$eventName = 'onAfter';
$handler = function (Event $event) {
echo "Hello {$event->owner->str}";
};
Event::on($object, $eventName, $handler);
Event::trigger($object, 'onAfter'); // output: Hello Rock!