Download the PHP package hetao29/phpcent2 without Composer
On this page you can find all versions of the php package hetao29/phpcent2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hetao29/phpcent2
More information about hetao29/phpcent2
Files in hetao29/phpcent2
Package phpcent2
Short Description Php library to communicate with Centrifugo v2.x
License MIT
Homepage https://github.com/centrifugal/phpcent
Informations about the package phpcent2
phpcent
PHP library to communicate with Centrifugo v5 HTTP API (for Centrifugo v4 use phpcent v5.x, for Centrifugo v3 use phpcent v4.x).
Library is published on the Composer: https://packagist.org/packages/centrifugal/phpcent
See Centrifugo server API documentation.
Basic Usage:
You can use phpcent to create connection token (JWT):
Connection token that will be valid for 5 minutes:
It's also possible to generate channel subscription token:
It's also possible to generate channel subscription token with expiration time, for example token for 30 mins:
Also API key and secret can be set in constructor:
Timeouts:
All available API methods:
To use assoc option while decoding JSON in response:
SSL
In case if your Centrifugo server has invalid SSL certificate, you can use:
You can also use self signed certificate in safe manner:
Note: Certificate must match with host name in Client address (localhost in example above).
DNS Resolution
This error may indicate your system is having trouble resolving IPv6 addresses:
By default, both IPv4 and IPv6 addresses will attempt to be resolved. You can force it to only resolve IPv4 addresses with:
Testing
Requirements:
The provided PHPUnit tests assume that a local Centrifugo server is running and available at port 8000. This can be accomplished using Docker and the official Centrifugo image.