PHP code example of justcoded / yii2-event-listener
1. Go to this page and download the library: Download justcoded/yii2-event-listener 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\listeners;
use justcoded\yii2\eventlistener\listeners\Listener;
use yii\base\Event;
/**
* Class SendUserGreeting
*/
class SendUserGreeting extends Listener
{
/**
* Handle action on event trigger.
*
* @param Event $event
*
* @return void
*/
public function handle(Event $event)
{
/* @var \app\models\User $sender */
$sender = $event->sender;
// TODO: write your code here, for example, send user greeting email after it was registered or created.
}
}