PHP code example of gbksoft / phpcent

1. Go to this page and download the library: Download gbksoft/phpcent 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/ */

    

gbksoft / phpcent example snippets


{
    "  "gbksoft/phpcent":"~1.0.5",
    }
}

        
        $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);