1. Go to this page and download the library: Download tomchanio/php_cent 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/ */
tomchanio / php_cent example snippets
return [
'url' => 'http://localhost:8000/api/', // full api url
'secret' => 'skoniksnyashamoyanikamuneotdam', // you super secret key
'apikey' => 'skoniksnyashamoyanikamuneotdam', // you api key
];
use Centrifugo;
class Controller
{
public function your_func()
{
// declare Centrifugo
$Centrifugo = new Centrifugo();
// generating token example
$userid = '1337_1448_228';
$info = ['token' => '123'];
$token = $Centrifugo->generateToken($userid, $info);
// publishing example
$Centrifugo->publish("channel" , ["yout text or even what rou want"]);
// each method returns its response;
// list of awailible methods:
$response = $Centrifugo->publish($channle, $messageData);
$response = $Centrifugo->broadcast($channles, $messageData);
$response = $Centrifugo->unsubscribe($channle, $userId);
$response = $Centrifugo->disconnect($userId);
$response = $Centrifugo->presence($channle);
$response = $Centrifugo->presence_stats($channle);
$response = $Centrifugo->history($channle);
$response = $Centrifugo->history_remove($channle);
$response = $Centrifugo->channels();
$response = $Centrifugo->info();
$response = $Centrifugo->generateToken($user);
// You can create a controller to bild your own interface;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.