Download the PHP package denis660/laravel-centrifugo without Composer
On this page you can find all versions of the php package denis660/laravel-centrifugo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download denis660/laravel-centrifugo
More information about denis660/laravel-centrifugo
Files in denis660/laravel-centrifugo
Package laravel-centrifugo
Short Description Centrifugo broadcaster for laravel
License MIT
Homepage https://github.com/denis660/laravel-centrifugo
Informations about the package laravel-centrifugo
Documentation EN | RU
Laravel + Centrifugo
Centrifugo broadcast driver for Laravel 9 - 13
Introduction
Centrifugo broadcaster for Laravel is based on:
Features
- Compatible with Centrifugo v6, verified up to v6.8.0 🚀
- Wrapper for Centrifugo HTTP API 🔌
- JWT token authentication (HMAC algorithm) for anonymous, authorized users, and private channels 🗝️
Requirements
- PHP 8.0 - 8.4
- Laravel 9 - 13
- Guzzlehttp/Guzzle 6 - 7
- Centrifugo Server v6 or newer (see here)
Installation
Select the version you need
| Version | PHP | Laravel | Centrifugo | Notes |
|---|---|---|---|---|
5.* |
>= 8.0 |
9 - 13 |
5-6 |
Current version |
3.0.* |
>= 7.4 |
8.75.* - 10 |
4-5 |
Previous version |
Install the package:
Then run the installer:
The installer will:
- add the
centrifugoconnection toconfig/broadcasting.php - add the required
CENTRIFUGO_*variables to.env - set both
BROADCAST_DRIVER=centrifugoandBROADCAST_CONNECTION=centrifugo - offer to run
php artisan install:broadcastingfor you if broadcasting scaffolding is missing
In fresh Laravel 11-13 applications, broadcasting is disabled by default, so letting the installer enable it for you is usually the simplest path.
Configuration
After centrifuge:install finishes, replace the generated values in .env with the real credentials from your Centrifugo server.
Credentials
To establish a connection with Centrifugo, you need to provide credentials from your Centrifugo server configuration. The installer generates placeholder values locally, but you should replace them with the actual values from your server.
Required parameters:
Optional parameters, modify if needed:
The installer configures both broadcasting environment variables in .env:
Client SDKs
For working with clients, see the Client SDK API
Here is a list of SDKs supported by Centrifugal Labs:
- JavaScript — for browser, NodeJS, and React Native
- Golang — for Go language
- Dart — for Dart and Flutter (mobile and web applications)
- Swift — for native iOS development
- Java — for native Android and general Java development
- Python — real-time SDK for Python on top of asyncio
Basic Usage
Set up your Centrifugo server as detailed in the official documentation For sending events, refer to the official Laravel documentation
Broadcast Driver Example
The package can be used as a Laravel broadcasting driver, not only as a direct HTTP API wrapper.
1. Create a broadcast event
2. Authorize the private channel
3. Dispatch the event
4. Expose an endpoint that returns a Centrifugo connection token
5. Connect and subscribe from the client
When Laravel broadcasts to new PrivateChannel('orders.123'), Laravel names the channel private-orders.123. This driver automatically converts that name to $orders.123 for Centrifugo, so clients should subscribe to the $... channel name.
Direct API Usage
Here is a simple example of client usage:
Methods for generating client tokens
| Method | Description |
|---|---|
| Generate a token for connection | |
| Generate a private token for a private channel |
The exp argument is a TTL in seconds. For a token valid for 5 minutes, pass 300, not time() + 300.
API Methods
| Method | Description |
|---|---|
| Send a message to a channel | |
| Send a message to multiple channels. | |
| Get presence information for a channel (all clients currently subscribed to this channel). | |
| Get summary information for a channel (number of clients). | |
| Get channel history (list of recent messages sent to the channel). | |
| Remove channel history. | |
| Subscribe a user to a channel | |
| Unsubscribe a user from a channel. | |
| Disconnect a user by their ID. | |
| List current active channels. | |
| Statistical information about running server nodes. |
License
MIT License. Please read the License File for more information.
Support the Project
USDT wallet:
Network:
Contributing 🤝
Issues and pull requests are welcome.
Before opening a PR:
- run
composer test - update both
README.mdandREADME_RU.mdif installation steps or public behavior changed - keep compatibility with the supported PHP and Laravel versions
All versions of laravel-centrifugo with dependencies
ext-json Version *
laravel/framework Version ^9.0|^10.0|^11.0|^12.0|^13.0
guzzlehttp/guzzle Version ~6.0|^7.0