Download the PHP package opekunov/laravel-centrifugo-broadcaster without Composer
On this page you can find all versions of the php package opekunov/laravel-centrifugo-broadcaster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download opekunov/laravel-centrifugo-broadcaster
More information about opekunov/laravel-centrifugo-broadcaster
Files in opekunov/laravel-centrifugo-broadcaster
Package laravel-centrifugo-broadcaster
Short Description Centrifugo broadcaster for laravel 8-9.x and Centrifugo >= 2.8.1
License MIT
Homepage https://github.com/opekunov/laravel-centrifugo-broadcaster
Informations about the package laravel-centrifugo-broadcaster
Documentation EN | RU
Laravel Centrifugo 4-5 Broadcaster
Centrifugo 4-5 broadcast driver for Laravel 8.75 - 11.x
For Centrifugo 2.8 - 3.x use version 1.2.6
Features
- Compatible with latest Centrifugo 5.x 🚀
- Wrapper over Centrifugo HTTP API 🔌
- Authentication with JWT token (HMAC algorithm) 🗝️
Requirements
- PHP >= 8.0
- Laravel 8.75 - 11.x
- guzzlehttp/guzzle 6 - 7
- Centrifugo Server 4.x or newer (see here)
Installation
For Centrifugo 2.8 - 3.x use version 1.2.6
Features
- Compatible with latest Centrifugo 5.x 🚀
- Wrapper over Centrifugo HTTP API 🔌
- Authentication with JWT token (HMAC algorithm) 🗝️
Requirements
- PHP >= 8.0
- Laravel 8.75 - 11.x
- guzzlehttp/guzzle 6 - 7
- Centrifugo Server 4.x or newer (see here)
Installation
Require this package with composer:
Open your config/app.php
and uncomment this line:
Open your config/broadcasting.php
and add new connection
like this:
Also you should add these two lines to your .env
file:
These lines are optional:
Don't forget to change BROADCAST_DRIVER
setting in .env file!
Basic Usage
To configure Centrifugo server, read official documentation
For broadcasting events, see official documentation of laravel
Channel authentication example:
Laravel
Frontend. See documentation centrifugal/centrifuge-js
Broadcasting example
Create event (for example SendMessage) with artisan php artisan make:event SendMessageEvent
A simple client usage example:
Available methods
Name | Description |
---|---|
publish(string $channel, array $data) | Send message into channel. |
broadcast(array $channels, array $data) | Send message into multiple channel. |
publishMany(array $data) | Send multiple data to multiple channels. $data - array of data arrays [channel, data] |
presence(string $channel) | Get channel presence information (all clients currently subscribed on this channel). |
presenceStats(string $channel) | Get channel presence information in short form (number of clients). |
history(string $channel) | Get channel history information (list of last messages sent into channel). |
historyRemove(string $channel) | Remove channel history information. |
unsubscribe(string $channel, string $user) | Unsubscribe user from channel. |
disconnect(string $userId) | Disconnect user by it's ID. |
channels() | Get channels information (list of currently active channels). |
info() | Get stats information about running server nodes. |
generateConnectionToken(string|int $userId, int|Carbon $exp = 0, array $info = []) | Generate connection token. |
generateSubscriptionToken(string|int $userId, string $channel, int|Carbon $exp = 0, array $info = [], array $override = []) | Generate subscription token. |
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-centrifugo-broadcaster with dependencies
laravel/framework Version ^8.75|^9.0|^10.0|^11.0|^12.0
guzzlehttp/guzzle Version ~6.0|^7.0
ext-json Version *