centrifugal/phpcent
PHP client for Centrifugo v5 HTTP API. Publish and broadcast to channels, manage subscriptions, presence and history, and run batch calls. Also generates JWT connection and subscription tokens. Composer-ready with configurable timeouts.
Laravel Native Compatibility: The package is PHP-centric and Laravel-agnostic but integrates effortlessly with Laravel’s ecosystem. It uses cURL under the hood, which aligns with Laravel’s HTTP client abstractions (e.g., HttpClient facade or Guzzle integration). The Client class can be dependency-injected into Laravel services, controllers, or jobs, enabling clean separation of concerns.
Client can be registered as a singleton in Laravel’s container, with configurable API keys/secrets via .env or config files.phpcent (e.g., publish to a channel when an OrderCreated event fires).Centrifugo Alignment: The package is tightly coupled to Centrifugo’s HTTP API (v5), which is a real-time messaging server optimized for pub/sub, presence, and push notifications. This fit is ideal for:
Anti-Patterns:
publish, broadcast, generateToken, etc.) that maps directly to Centrifugo’s HTTP endpoints. Laravel’s facades or helpers can wrap phpcent for consistency.
// Laravel Service Provider
$this->app->singleton(\phpcent\Client::class, function ($app) {
return new \phpcent\Client(
config('centrifugo.api_url'),
config('centrifugo.api_key'),
config('centrifugo.secret_key')
);
});
generateConnectionToken/generateSubscriptionToken).phpcent versions in composer.json and monitor Centrifugo’s changelog.retry helpers or exponential backoff for HTTP calls..env.MockHttpClient or Dockerized Centrifugo for CI tests (as shown in the package’s README).phpcent\Client as a singleton with configurable options (e.g., timeouts, SSL).Centrifugo facade to simplify usage (e.g., Centrifugo::publish('channel', $data)).phpcent publishes from Laravel events (e.g., OrderCreated → publish to orders.{user_id}).CentrifugoPublishJob).config/centrifugo.php (e.g., api_key, secret_key, url).centrifuge/centrifuge) for frontend connections.phpcent.phpcent\Client in Laravel’s container.phpcent’s PHP 7.4+ requirement.phpcent v5.x if using Centrifugo v4.firebase/php-jwt for token generation (auto-installed via Composer).setCert()) and disabled checks (setSafety(false))..env with Centrifugo credentials.phpcent via Composer.Client in Laravel’s AppServiceProvider.publish/broadcast for notifications.How can I help you explore Laravel packages today?