1. Go to this page and download the library: Download kismia/centrifugo-bundle 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/ */
kismia / centrifugo-bundle example snippets
public function registerBundles()
{
$bundles = [
.......
new \Kismia\CentrifugoBundle\CentrifugoBundle()
];
}
$userId = 1;
$channel = '#chan_1';
$messageData = ['message' => 'Hello, world!'];
//instance of Centrifugo client class
$centrifugo = $this->get('centrifugo.client');
//Send message into channel.
$response = $centrifugo->publish($channel, $messageData);
//Very similar to publish but allows to send the same data into many channels.
$response = $centrifugo->broadcast($channels, $messageData);
//Unsubscribe user from channel.
$response = $centrifugo->unsubscribe($channel, $userId);
//Disconnect user by user ID.
$response = $centrifugo->disconnect($userId);
//Get channel presence information (all clients currently subscribed on this channel).
$response = $centrifugo->presence($channel);
//Get channel history information (list of last messages sent into channel).
$response = $centrifugo->history($channel);
//Get channels information (list of currently active channels).
$response = $centrifugo->channels();
//Get stats information about running server nodes.
$response = $centrifugo->stats();
//Get information about single Centrifugo node.
$response = $centrifugo->node('http://node1.example.com/api/');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.