PHPackages                             teamones/phpcent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. teamones/phpcent

ActiveLibrary[HTTP &amp; Networking](/categories/http)

teamones/phpcent
================

PHP library to communicate with Centrifugo HTTP API（use workerman support async request）

4.1.0(4y ago)039MITPHPPHP &gt;=5.4.0

Since Jun 30Pushed 4y agoCompare

[ Source](https://github.com/teamones-open/phpcent)[ Packagist](https://packagist.org/packages/teamones/phpcent)[ Docs](https://github.com/centrifugal/phpcent)[ RSS](/packages/teamones-phpcent/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (4)Used By (0)

phpcent
=======

[](#phpcent)

[![Build Status](https://camo.githubusercontent.com/934c67021dcdf79a5a4a581691d13061d2a7aa8cef5750c731c9abd1e03771fc/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f63656e747269667567616c2f70687063656e742e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/centrifugal/phpcent)[![Latest Version](https://camo.githubusercontent.com/3605fe4d9a8b32914ba003c21ff18bbd8b72132c974c6e30845c11cf5557fc03/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f63656e747269667567616c2f70687063656e742e7376673f7374796c653d666c61742d737175617265)](https://github.com/centrifugal/phpcent/releases)

PHP library to communicate with Centrifugo v2 HTTP API.

Library is published on the Composer:

```
composer require centrifugal/phpcent:~3.0
```

See [Centrifugo documentation](https://centrifugal.github.io/centrifugo/)

Basic Usage:

```
$client = new \phpcent\Client("http://localhost:8000/api");
$client->setApiKey("Centrifugo API key");
$client->publish("channel", ["message" => "Hello World"]);
```

You can use `phpcent` to create connection token (JWT):

```
$token = $client->setSecret("Centrifugo secret key")->generateConnectionToken($userId);
```

Connection token that will be valid for 5 minutes:

```
$token = $client->setSecret("Centrifugo secret key")->generateConnectionToken($userId, time() + 5*60);
```

It's also possible to generate private channel subscription token:

```
$token = $client->setSecret("Centrifugo secret key")->generatePrivateChannelToken($client, $channel);
```

Also API key and secret can be set in constructor:

```
$client = new \phpcent\Client("http://localhost:8000/api", "Centrifugo API key", "Centrifugo secret key");
```

Timeouts:

```
$client->setConnectTimeoutOption(0); // Seconds | 0 = never
$client->setTimeoutOption(2); // Seconds
```

All available API methods:

```
$response = $client->publish($channel, $data);
$response = $client->broadcast($channels, $data);
$response = $client->unsubscribe($channel, $userId);
$response = $client->disconnect($userId);
$response = $client->presence($channel);
$response = $client->presenceStats($channel);
$response = $client->history($channel);
$response = $client->historyRemove($channel);
$response = $client->channels();
$response = $client->info();
```

To use `assoc` option while decoding JSON in response:

```
$client->setUseAssoc(true);
```

### SSL

[](#ssl)

In case if your Centrifugo server has invalid SSL certificate, you can use:

```
$client->setSafety(false);
```

You can also use self signed certificate in safe manner:

```
$client = new \phpcent\Client("https://localhost:8000/api");
$client->setCert("/path/to/certificate.pem");
$client->setCAPath("/ca/path"); // if you need.
```

*Note:* Certificate must match with host name in `Client` address (`localhost` in example above).

### DNS Resolution

[](#dns-resolution)

This error may indicate your system is having trouble resolving IPv6 addresses:

```
cURL error: Resolving timed out after [value] milliseconds

```

By default, both IPv4 and IPv6 addresses will attempt to be resolved. You can force it to only resolve IPv4 addresses with:

```
$client->forceIpResolveV4();
```

### Testing

[](#testing)

Requirements:

- git
- A supported version of PHP
- [composer](http://getcomposer.org/download)
- [Docker](https://www.docker.com/products/docker-desktop)

The provided PHPUnit tests assume that a local [Centrifugo](https://github.com/centrifugal/centrifugo) server is running and available at port 8000. This can be accomplished using Docker and the [official Centrifugo image](https://hub.docker.com/r/centrifugo/centrifugo/).

```
# Install package dependencies.
$ composer install

# The following command starts a Centrifugo server running in a background Docker container.
$ docker run -d -p 8000:8000 --name centrifugo centrifugo/centrifugo centrifugo --api_insecure

# Run the test suite.
$ vendor/bin/phpunit

# Shut down the Centrifugo container.
$ docker stop centrifugo
```

Authors
=======

[](#authors)

- [Dmitriy Soldatenko](https://github.com/sl4mmer)
- [Dmitriy Tetekin](https://github.com/Tomchanskiy)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1774d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a5a829c6c41a7e0af82f69fdc179b7d64d3dbc323e2670ddeed90e4e4e9dc2cb?d=identicon)[weijer](/maintainers/weijer)

---

Top Contributors

[![FZambia](https://avatars.githubusercontent.com/u/1196565?v=4)](https://github.com/FZambia "FZambia (32 commits)")[![sl4mmer](https://avatars.githubusercontent.com/u/1143307?v=4)](https://github.com/sl4mmer "sl4mmer (30 commits)")[![weijer](https://avatars.githubusercontent.com/u/12838756?v=4)](https://github.com/weijer "weijer (3 commits)")[![khvalov](https://avatars.githubusercontent.com/u/2668527?v=4)](https://github.com/khvalov "khvalov (2 commits)")[![Vovan-VE](https://avatars.githubusercontent.com/u/1166581?v=4)](https://github.com/Vovan-VE "Vovan-VE (2 commits)")[![beporter](https://avatars.githubusercontent.com/u/637270?v=4)](https://github.com/beporter "beporter (2 commits)")[![jumper572](https://avatars.githubusercontent.com/u/29145733?v=4)](https://github.com/jumper572 "jumper572 (2 commits)")[![yagobski](https://avatars.githubusercontent.com/u/220980?v=4)](https://github.com/yagobski "yagobski (1 commits)")[![Darkkin](https://avatars.githubusercontent.com/u/8968720?v=4)](https://github.com/Darkkin "Darkkin (1 commits)")[![juliustm](https://avatars.githubusercontent.com/u/3254503?v=4)](https://github.com/juliustm "juliustm (1 commits)")[![SteveTherrien](https://avatars.githubusercontent.com/u/9618303?v=4)](https://github.com/SteveTherrien "SteveTherrien (1 commits)")[![Tomchanskiy](https://avatars.githubusercontent.com/u/34372563?v=4)](https://github.com/Tomchanskiy "Tomchanskiy (1 commits)")[![xAockd](https://avatars.githubusercontent.com/u/3390348?v=4)](https://github.com/xAockd "xAockd (1 commits)")[![aleksraiden](https://avatars.githubusercontent.com/u/65920?v=4)](https://github.com/aleksraiden "aleksraiden (1 commits)")

---

Tags

websocketmessagingrealtimecentrifugo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/teamones-phpcent/health.svg)

```
[![Health](https://phpackages.com/badges/teamones-phpcent/health.svg)](https://phpackages.com/packages/teamones-phpcent)
```

###  Alternatives

[centrifugal/phpcent

PHP library to communicate with Centrifugo HTTP API

1822.3M4](/packages/centrifugal-phpcent)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M292](/packages/pusher-pusher-php-server)[sl4mmer/phpcent

PHP library to communicate with Centrifugo HTTP API

182293.0k1](/packages/sl4mmer-phpcent)[denis660/laravel-centrifugo

Centrifugo broadcaster for laravel

113164.7k](/packages/denis660-laravel-centrifugo)[basement-chat/basement-chat

Add a real-time chat widget to your Laravel application.

4983.9k](/packages/basement-chat-basement-chat)[vinelab/minion

A Simple WAMP (Web Application Messaging Protocol) server and command line tool

1276.4k](/packages/vinelab-minion)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
