1. Go to this page and download the library: Download tomwright/eventing 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/ */
tomwright / eventing example snippets
namespace App\Eventing\Event;
class UserWasRegistered extends \TomWright\Eventing\Event\Event
{
protected $userId;
public function setUserId($userId)
{
$this->userId = $userId;
}
public function getUserId()
{
return $this->userId;
}
}
namespace App\Eventing\Handler;
class UserWasRegisteredHandler implements \TomWright\Eventing\Listener\ListenerInterface
{
public function handle(\TomWright\Eventing\Event\EventInterface $event)
{
echo "User #{$event->getUserId()} has been registered.";
}
}