A observable triat for PHP.
composer require bephp/observable
add event
remove event
trigger event
class A{
use Observable;
}
$a = new A();
$a->on('hello', function($name){
echo 'hello ', $name, '!';
});
$a->trigger('hello', 'lloyd');
this demo will get result:
hello lloyd!