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

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

pavelmgn/laravel-centrifugo
===========================

Centrifugo broadcaster for laravel

v0.0.1.x-dev(3mo ago)04MITPHPPHP ^8.0

Since Mar 20Pushed 3mo agoCompare

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

READMEChangelogDependencies (4)Versions (2)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 - 12
----------------------------------------------

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

[![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)[![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)

- Compatibility with the latest version of [Centrifugo v6.2.3](https://github.com/centrifugal/centrifugo/releases/tag/v6.2.3) 🚀
- 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 - 12
- Guzzlehttp/Guzzle 6 - 7
- Centrifugo Server v6 or newer (see [here](https://github.com/centrifugal/centrifugo))

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

[](#installation)

For Laravel 9-10:

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

For Laravel 11-12, there are specific instructions below.

##### Select the version you need

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

VersionPHPLaravelCentrifugoNotes`5.*``>= 8.0``9` - `12``5-6`**Current version**`3.0.*``>= 7.4``8.75.*` - `10``4`-`5`Previous versionBy default, broadcasting is disabled in new Laravel 11 applications. You can enable broadcasting using the install Artisan command:

```
php artisan install:broadcasting
```

If asked whether to install Reverb, answer “no.”

Then, install the package for working with Centrifugo via composer by running the following command:

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

Configuration
-------------

[](#configuration)

Run the `centrifuge:install` command, which will publish the configuration file and generate the necessary environment variables in your `.env` file with default values.

```
php artisan centrifuge:install
```

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

[](#credentials)

To establish a connection with Centrifugo, you need to provide credentials from your Centrifugo server's `config.json` file. Laravel will generate example keys that you should replace with your actual server credentials. You can specify these credentials with the following environment variables:

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

```

Make sure to check the `BROADCAST_DRIVER` parameter in the .env file:

```
BROADCAST_DRIVER=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/11.x/broadcasting)

Here is a simple example of client usage:

```
