PHP code example of odannyc / yii2-sse
1. Go to this page and download the library: Download odannyc/yii2-sse 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/ */
odannyc / yii2-sse example snippets
use odannyc\Yii2SSE\SSEBase;
class MessageEventHandler extends SSEBase
{
public function check()
{
return true;
}
public function update()
{
return "Something Cool";
}
}
php
'components' => [
...
'sse' => [
'class' => \odannyc\Yii2SSE\LibSSE::class
]
...
];
php
public function actionIndex()
{
$sse = Yii::$app->sse;
$sse->addEventListener('message', new MessageEventHandler());
$sse->start();
}