hetao29 / phpcent2
Php library to communicate with Centrifugo v2.x
2.0.1
2018-11-01 08:30 UTC
Requires
- php: >=5.3.0
- ext-curl: *
- ext-json: *
- firebase/php-jwt: >=5.0.0
Requires (Dev)
- firebase/php-jwt: >=5.0.0
This package is auto-updated.
Last update: 2025-01-15 17:58:09 UTC
README
Php library to communicate with Centrifugo HTTP API.
Library is published on the Composer: https://packagist.org/packages/sl4mmer/phpcent
{ "require": { "hetao29/phpcent2":"dev-master", } }
Basic Usage:
//to backend api $client = new \phpcent2\Client("http://localhost:8000"); $client->setApikey("api key from Centrifugo");//to backend api $client->publish("main_feed", ["message" => "Hello Everybody"]); $history = $client->history("main_feed"); //to get token $client->setSecret("secret key from Centrifugo"); $token = $client->getToken([ "data"=>[], "sub"=>1 ]);
You can use phpcent2
to create frontend token:
$token = $client->setSecret($pSecret)->getToken($data);
SSL
In case if your Centrifugo server has invalid SSL certificate, you can use:
\phpcent2\Transport::setSafety(\phpcent\Transport::UNSAFE);
Since 1.0.5 you can use self signed certificate in safe manner:
$client = new \phpcent2\Client("https://localhost:8000"); $client->setSecret("secret key from Centrifugo"); $transport = new \phpcent2\Transport(); $transport->setCert("/path/to/certificate.pem"); $client->setTransport($transport);
Note: Certificate must match with host name in Client
address (localhost
in example above).
Alternative clients
- php-centrifugo - allows to work with Redis Engine API queue.
- php_cent by skoniks