1. Go to this page and download the library: Download mozartk/simple-event 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/ */
mozartk / simple-event example snippets
mozartk\SimpleEvent\SimpleEvent;
$event = new SimpleEvent();
$event->set("event1", function(){
return "Hello World";
});
$result = $event->emit("testEvent");
echo $result; //return Hello World
$event->one("event2", function(){
return 111;
});
$result = $event->emit("testEvent");
echo $result; //return 1
$result = $event->emit("testEvent"); //Exceptions on this line.