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