PHPackages                             laracomponents/centrifuge-broadcaster - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. laracomponents/centrifuge-broadcaster

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laracomponents/centrifuge-broadcaster
=====================================

Centrifuge broadcaster for laravel &gt;= 5.3

v1.0.4(8y ago)227.5k↓43.8%9[2 issues](https://github.com/LaraComponents/centrifuge-broadcaster/issues)MITPHPPHP &gt;=5.6.4

Since Apr 8Pushed 7y ago3 watchersCompare

[ Source](https://github.com/LaraComponents/centrifuge-broadcaster)[ Packagist](https://packagist.org/packages/laracomponents/centrifuge-broadcaster)[ Docs](https://github.com/LaraComponents/centrifuge-broadcaster)[ RSS](/packages/laracomponents-centrifuge-broadcaster/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

Centrifuge Broadcaster for Laravel 5
====================================

[](#centrifuge-broadcaster-for-laravel-5)

[![Build Status](https://camo.githubusercontent.com/1685faf985d2c50dc69ca1296906751c4db1231f0cb89d0831b3135b6b8f9b44/68747470733a2f2f7472617669732d63692e6f72672f4c617261436f6d706f6e656e74732f63656e747269667567652d62726f61646361737465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/LaraComponents/centrifuge-broadcaster)[![Latest Version](https://camo.githubusercontent.com/4501235cffe2b794531cc25aa10e7ebe7423de41816b5995f0faaea39421e124/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4c617261436f6d706f6e656e74732f63656e747269667567652d62726f61646361737465722e7376673f7374796c653d666c61742d737175617265)](https://github.com/LaraComponents/centrifuge-broadcaster/releases)[![Quality Score](https://camo.githubusercontent.com/cefa60a65ef6edb11593607d767bdc6b285538e2fb3910f095fb8cdc394726e9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f4c617261436f6d706f6e656e74732f63656e747269667567652d62726f61646361737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/LaraComponents/centrifuge-broadcaster)[![StyleCI](https://camo.githubusercontent.com/b223a769e97c9498911204a838cb8e6887407350db84c9f23280c7d40467638d/68747470733a2f2f7374796c6563692e696f2f7265706f732f37373430303534342f736869656c64)](https://styleci.io/repos/77400544)[![Total Downloads](https://camo.githubusercontent.com/2af78f6fd9b62b8f1d61c32a267f3c30c1bb6c6ff0299043b352aeee092bb7e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4c617261436f6d706f6e656e74732f63656e747269667567652d62726f61646361737465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/LaraComponents/centrifuge-broadcaster)[![Software License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/LaraComponents/centrifuge-broadcaster/blob/master/LICENSE)

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

[](#introduction)

Centrifuge broadcaster for laravel &gt;= 5.3

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

[](#requirements)

- PHP 5.6.4+ or newer
- Laravel 5.3 or newer
- Centrifugo Server 1.6.1 or newer (see [here](https://github.com/centrifugal/centrifugo))

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

[](#installation)

Require this package with composer:

```
composer require laracomponents/centrifuge-broadcaster
```

Open your config/app.php and add the following to the providers array:

```
'providers' => [
    // ...
    LaraComponents\Centrifuge\CentrifugeServiceProvider::class,

    // And uncomment BroadcastServiceProvider
    App\Providers\BroadcastServiceProvider::class,
],
```

Open your config/broadcasting.php and add the following to it:

```
'connections' => [
    'centrifuge' => [
        'driver' => 'centrifuge',
        'secret' => env('CENTRIFUGE_SECRET'), // you secret key
        'url' => env('CENTRIFUGE_URL', 'http://localhost:8000'), // centrifuge api url
        'redis_api' => env('CENTRIFUGE_REDIS_API', false), // enable or disable Redis API
        'redis_connection' => env('CENTRIFUGE_REDIS_CONNECTION', 'default'), // name of redis connection
        'redis_prefix' => env('CENTRIFUGE_REDIS_PREFIX', 'centrifugo'), // prefix name for queue in Redis
        'redis_num_shards' => env('CENTRIFUGE_REDIS_NUM_SHARDS', 0), // number of shards for redis API queue
        'verify' => env('CENTRIFUGE_VERIFY', false), // Verify host ssl if centrifuge uses this
        'ssl_key' => env('CENTRIFUGE_SSL_KEY', null), // Self-Signed SSl Key for Host (require verify=true)
    ],
    // ...
],
```

For the redis configuration, add a new connection in config/database.php

```
'redis' => [
    'centrifuge' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),,
        'password' => env('REDIS_PASSWORD', null),
        'port' =>  env('REDIS_PORT', 6379),
        'database' => 0,
    ],
    // ...
],
```

You can also add a configuration to your .env file:

```
CENTRIFUGE_SECRET=very-long-secret-key
CENTRIFUGE_URL=http://localhost:8000
CENTRIFUGE_REDIS_API=false
CENTRIFUGE_REDIS_CONNECTION=centrifuge
CENTRIFUGE_REDIS_PREFIX=centrifugo
CENTRIFUGE_REDIS_NUM_SHARDS=0
CENTRIFUGE_SSL_KEY=/etc/ssl/some.pem
CENTRIFUGE_VERIFY=false

```

Do not forget to install the broadcast driver

```
BROADCAST_DRIVER=centrifuge

```

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

[](#basic-usage)

To configure the Centrifugo server, read the [official documentation](https://fzambia.gitbooks.io/centrifugal/content)

For broadcasting events, see the [official documentation of laravel](https://laravel.com/docs/5.3/broadcasting)

A simple example of using the client:

```
