PHP code example of beekirr / centrifugal-php-client

1. Go to this page and download the library: Download beekirr/centrifugal-php-client 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/ */

    

beekirr / centrifugal-php-client example snippets


{
    "  "sl4mmer/phpcent":"dev-master",
    }
}

        
        $client = new \phpcent\Client("http://localhost:8000");
        $client->setSecret("secret key from Centrifugo");
        $client->publish("main_feed", ["message" => "Hello Everybody"]);
        $history = $client->history("main_feed");
        

	$token = $client->setSecret($pSecret)->generateClientToken($user, $timestamp);

	$sign = $client->setSecret($pSecret)->generateClientToken($client, $channel);

$client->broadcast(['example:entities', 'example:moar'], ['user_id' => 2321321, 'state' => '1']);

\phpcent\Transport::setSafety(\phpcent\Transport::UNSAFE);

$client = new \phpcent\Client("https://localhost:8000");
$client->setSecret("secret key from Centrifugo");
$transport = new \phpcent\Transport();
$transport->setCert("/path/to/certificate.pem");
$client->setTransport($transport);