1. Go to this page and download the library: Download guanguans/yii-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/ */
namespace app\events;
use yii\base\Event;
class ExampleEvent extends Event
{
public $name = 'example';
}
namespace app\listeners;
use Guanguans\YiiEvent\ListenerInterface;
use yii\base\Event;
class ExampleListener implements ListenerInterface
{
public function handle(Event $event)
{
// to do something.
var_export($event->name);
// var_export($event->data);
}
}