PHPackages                             denis660/laravel-centrifugo - 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. denis660/laravel-centrifugo

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

denis660/laravel-centrifugo
===========================

Centrifugo broadcaster for laravel

v5.2(10mo ago)113164.7k—7.4%25[1 issues](https://github.com/denis660/laravel-centrifugo/issues)MITPHPPHP ^8.0CI failing

Since Jan 11Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/denis660/laravel-centrifugo)[ Packagist](https://packagist.org/packages/denis660/laravel-centrifugo)[ Docs](https://github.com/denis660/laravel-centrifugo)[ RSS](/packages/denis660-laravel-centrifugo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (18)Used By (0)

Documentation **EN** | [RU](https://github.com/denis660/laravel-centrifugo/blob/master/README_RU.md)

Laravel + Centrifugo
====================

[](#laravel--centrifugo)

Centrifugo broadcast driver for Laravel 9 - 13
----------------------------------------------

[](#centrifugo-broadcast-driver-for-laravel-9---13)

[![Build Status](https://github.com/denis660/laravel-centrifugo/actions/workflows/tests.yml/badge.svg)](https://github.com/denis660/laravel-centrifugo/actions/workflows/tests.yml)[![Latest Version](https://camo.githubusercontent.com/5b3e1f3941c29b314d258b01b54413d6d9ff36f120c9ce00c29511491835b9e5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f64656e69733636302f6c61726176656c2d63656e7472696675676f2e7376673f7374796c653d666c61742d737175617265)](https://github.com/denis660/laravel-centrifugo/releases)[![Total Downloads](https://camo.githubusercontent.com/67b62e6373af83aa1402f183721b13ee44f665578afb00374cad49b60975f626/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64656e69733636302f6c61726176656c2d63656e7472696675676f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/denis660/laravel-centrifugo)[![PHP Version](https://camo.githubusercontent.com/20a8bbf0c510647811e9f57ca36a6dabccfd12f6c8a05aed5d648149a8258a68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64656e69733636302f6c61726176656c2d63656e7472696675676f)](https://packagist.org/packages/denis660/laravel-centrifugo)[![Laravel Version](https://camo.githubusercontent.com/0f7c6f2d493a0edd152cfa3ec3b20a351492c73ec7e08d7992d49c0366efa28b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64656e69733636302f6c61726176656c2d63656e7472696675676f)](https://packagist.org/packages/denis660/laravel-centrifugo)[![Coverage](https://camo.githubusercontent.com/50a4fbc8e51d67d8814fd8ab90d2cbd132da38b8d00c18c96634f969c20867a8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e3f7374796c653d666c61742d737175617265)](https://github.com/denis660/laravel-centrifugo/blob/master/build/logs/clover.xml)[![Software License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/denis660/laravel-centrifugo/blob/master/LICENSE)

Introduction
------------

[](#introduction)

Centrifugo broadcaster for Laravel is based on:

- [centrifugal/phpcent](https://github.com/centrifugal/phpcent)

Features
--------

[](#features)

- Compatible with Centrifugo v6, verified up to [v6.7.0](https://github.com/centrifugal/centrifugo/releases/tag/v6.7.0) 🚀
- Wrapper for [Centrifugo HTTP API](https://centrifugal.dev/docs/server/server_api) 🔌
- JWT token authentication (HMAC algorithm) for anonymous, authorized users, and private channels 🗝️

Requirements
------------

[](#requirements)

- PHP 8.0 - 8.4
- Laravel 9 - 13
- Guzzlehttp/Guzzle 6 - 7
- Centrifugo Server v6 or newer (see [here](https://github.com/centrifugal/centrifugo))

Installation
------------

[](#installation)

##### Select the version you need

[](#select-the-version-you-need)

VersionPHPLaravelCentrifugoNotes`5.*``>= 8.0``9` - `13``5-6`**Current version**`3.0.*``>= 7.4``8.75.*` - `10``4`-`5`Previous versionInstall the package:

```
composer require denis660/laravel-centrifugo
```

Then run the installer:

```
php artisan centrifuge:install
```

The installer will:

- add the `centrifugo` connection to `config/broadcasting.php`
- add the required `CENTRIFUGO_*` variables to `.env`
- set both `BROADCAST_DRIVER=centrifugo` and `BROADCAST_CONNECTION=centrifugo`
- offer to run `php artisan install:broadcasting` for 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
-------------

[](#configuration)

After `centrifuge:install` finishes, replace the generated values in `.env` with the real credentials from your Centrifugo server.

Credentials
===========

[](#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:

```
CENTRIFUGO_TOKEN_HMAC_SECRET_KEY=token_hmac_secret_key-from-centrifugo-config
CENTRIFUGO_API_KEY=api_key-from-centrifugo-config

```

Optional parameters, modify if needed:

```
CENTRIFUGO_URL=http://localhost:8000
CENTRIFUGO_SSL_KEY=/etc/ssl/some.pem
CENTRIFUGO_VERIFY=false

```

The installer configures both broadcasting environment variables in `.env`:

```
BROADCAST_DRIVER=centrifugo
BROADCAST_CONNECTION=centrifugo

```

Client SDKs
-----------

[](#client-sdks)

For working with clients, see the [Client SDK API](https://centrifugal.dev/docs/transports/client_api)

Here is a list of SDKs supported by Centrifugal Labs:

- [JavaScript](https://github.com/centrifugal/centrifuge-js) — for browser, NodeJS, and React Native
- [Golang](https://github.com/centrifugal/centrifuge-go) — for Go language
- [Dart](https://github.com/centrifugal/centrifuge-dart) — for Dart and Flutter (mobile and web applications)
- [Swift](https://github.com/centrifugal/centrifuge-swift) — for native iOS development
- [Java](https://github.com/centrifugal/centrifuge-java) — for native Android and general Java development
- [Python](https://github.com/centrifugal/centrifuge-python) — real-time SDK for Python on top of asyncio

Basic Usage
-----------

[](#basic-usage)

Set up your Centrifugo server as detailed in the [official documentation](https://centrifugal.dev)For sending events, refer to the [official Laravel documentation](https://laravel.com/docs/13.x/broadcasting)

Broadcast Driver Example
------------------------

[](#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

[](#1-create-a-broadcast-event)

```
