Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpcent Laravel Package

centrifugal/phpcent

PHP client library for Centrifugo v5 HTTP API. Publish, broadcast, subscribe, manage presence and history, plus generate JWT connection and subscription tokens. Install via Composer with composer require centrifugal/phpcent:~6.0.

View on GitHub
Deep Wiki
Context7

PHP SDK for Centrifugo's HTTP server API: every API method, tokens, proxy handlers and the endpoints client SDKs call

Frequently asked questions about Phpcent
How do I install phpcent in a Laravel app with Composer?
Run composer require centrifugal/phpcent:~6.0. The package is PSR-4 autoloaded and depends on ext-curl, with no compilation or extra extension required. After install, create a phpcent\Client with your Centrifugo API URL and API key, or bind it as a singleton in Laravel's service container.
Does phpcent work with Laravel out of the box?
Not fully. phpcent ships no Laravel service provider and no facade, and there is no first-party Laravel broadcasting driver. You can register the client as a container singleton, but broadcasting Eloquent events to Centrifugo requires custom listener-to-publisher glue of roughly 20 to 40 lines. Laravel's BroadcastManager expects Pusher-protocol drivers, so plan that glue deliberately.
Which Centrifugo version does phpcent 6.x support?
phpcent 6.x speaks the Centrifugo v5 HTTP API. For Centrifugo v4 use phpcent v5.x, and for Centrifugo v3 use phpcent v4.x. Treat the server and library as a versioned pair: pin both and schedule upgrades in lockstep, because a Centrifugo upgrade forces a matching client upgrade and redeploy.
How do I publish or broadcast a message to Centrifugo from PHP?
Create a Client with the Centrifugo /api endpoint, call setApiKey with your API key, then call publish with a channel and data array. Use broadcast to send to multiple channels, and batch for grouped API calls. The API key is server-side only and must never be exposed to browsers.
How do I generate Centrifugo connection and subscription tokens in PHP?
Call setSecret with the Centrifugo secret key, then generateConnectionToken for a user ID or generateSubscriptionToken for a user and channel. Both accept an optional expiration timestamp, such as time() plus 300 for five minutes. Token minting is local computation with no network call, but the secret must match Centrifugo's token configuration.
How do I configure timeouts for phpcent HTTP calls?
Use setConnectTimeoutOption and setTimeoutOption, both in seconds; a connect timeout of 0 means never. Keep both short in web requests so a slow Centrifugo cannot tie up PHP-FPM workers. These two knobs are the main defense against latency cascading into your Laravel app.
What are the production risks of calling phpcent inside a Laravel request?
The main risk is that every publish is synchronous HTTP and blocks a PHP-FPM worker. Under a publish storm this can exhaust workers and degrade the whole application, not just real-time features. Queue publishes or move them to background jobs, keep timeouts short, and add message IDs plus consumer-side dedupe because phpcent has no built-in retry or idempotency. A timed-out publish may still have succeeded server-side.
How can I test phpcent against Centrifugo in CI?
Use the README's Docker harness: run the centrifugo/centrifugo image on port 8000 with the --api_insecure flag, then exercise phpcent calls from PHPUnit. That pattern can be lifted into CI almost verbatim and keeps verification cost low. Never use --api_insecure in production.
Is phpcent secure for production, or does setSafety(false) disable TLS?
Treat setSafety(false) as a production red flag: it disables TLS verification outright. The documented Docker harness also runs Centrifugo with --api_insecure, which is fine only for local tests. In production, use HTTPS, verify TLS, keep API keys and JWT secrets server-side, and never expose them to the browser SDK.
What are the alternatives to phpcent and how hard is it to replace?
Lock-in is low: phpcent is a thin HTTP client with roughly a dozen methods plus JWT minting, and the MIT license permits forking. If the package stalls, a 150 to 250 line Guzzle wrapper can reproduce the surface in days. The trade-off is a small maintainer base, few third-party bug reports and no support SLA, even though this is the official Centrifugo client.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels