PHP code example of codememory / event-dispatcher
1. Go to this page and download the library: Download codememory/event-dispatcher 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/ */
codememory / event-dispatcher example snippets
namespace App\Events;
use Codememory\Components\Event\Interfaces\EventInterface;
class OutputTextEvent implements EventInterface
{
/**
* @inheritDoc
*/
public function getListeners() : array
{
return [];
}
}
use Codememory\Components\Event\EventDispatcher;
use App\Events\OutputTextEvent;
class)
->addListener(function (OutputTextEvent $event) {
echo 123;
});
use Codememory\Components\Event\Dispatcher;
$dispatcher = new Dispatcher();
$dispatcher->dispatch(OutputTextEvent::class);
// 123