PHP code example of lucid / signal

1. Go to this page and download the library: Download lucid/signal 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/ */

    

lucid / signal example snippets




use Lucid\Signal\EventInterface;
use Lucid\Signal\EventDispatcher;

$dispatcher = new EventDispatcher;

$dispatcher->addHandler('my_event', function (EventInterface $event) {
	// do something
});



use Lucid\Signal\EventInterface;
use Lucid\Signal\HandlerInterface;
use Lucid\Signal\EventDispatcher;

class MyHandler implements HandlerInterface
{
	public function handleEvent(EventInterface $event)
	{
		// do something
	}
}



$dispatcher = new EventDispatcher;
$handler = new MyHandler;

$dispatcher->addHandler('my_event', $handler);




namespace Acme\Message;

use Lucid\Signal\Event;

class SysMessage extends Event
{
	private $message;

	public function setMessage($message)
	{
		$this->message = $message;
	}

	public function getMessage()
	{
		return $this->message;
	}
}

php >= 5.6