PHP code example of dickyermawan / yii2-socketio
1. Go to this page and download the library: Download dickyermawan/yii2-socketio 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/ */
dickyermawan / yii2-socketio example snippets
//in components array
'socket' => [
'class' => 'dickyermawan\socketio\ElephantIo',
'host' => 'http://localhost:8089',
'options' => [
'headers' => [
'X-My-Header: MyHead',
'Authorization: Bearer 12345asdf'
]
]
]
//in your controller:
Yii::$app->socket->emit('realTime', [
'param1' => 'param1',
'param2' => 'param2'
]);
Yii::$app->socket->close();