1. Go to this page and download the library: Download echo-fusion/eventmanager 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/ */
echo-fusion / eventmanager example snippets
use EchoFusion\EventManager\EventManager;
use EchoFusion\EventManager\EventInterface;
// Create an instance of EventManager
$eventManager = new EventManager();
// Define the first listener
$listener1 = function (EventInterface $event) {
echo "Listener 1: The event '" . $event->getName() . "' was triggered!\n";
};
// Define the second listener
$listener2 = function (EventInterface $event) {
echo "Listener 2: The event '" . $event->getName() . "' was triggered!\n";
};
// Attach both listeners to an event named 'user.register'
$eventManager->attach('user.register', $listener1);
$eventManager->attach('user.register', $listener2);
// Create a new event
$event = new class('user.register') extends BaseEvent {
public function __construct(string $name)
{
$this->setName($name);
}
};
// Trigger the 'user.register' event, and both listeners will respond
$eventManager->trigger($event);
Listener 1: The event 'user.register' was triggered!
Listener 2: The event 'user.register' was triggered!
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.