PHPackages                             theardent/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. [API Development](/categories/api)
4. /
5. theardent/centrifuge-broadcaster

ActiveLibrary[API Development](/categories/api)

theardent/centrifuge-broadcaster
================================

Centrifuge broadcaster for laravel &gt;= 5.3, support Centrifuge v2

v1.0.21(5y ago)52.4k3MITPHPPHP &gt;=5.6.4CI failing

Since Jan 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/TheArdent/centrifuge-broadcaster)[ Packagist](https://packagist.org/packages/theardent/centrifuge-broadcaster)[ Docs](https://github.com/TheArdent/centrifuge-broadcaster)[ RSS](/packages/theardent-centrifuge-broadcaster/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (5)Used By (0)

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

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

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

[](#introduction)

Centrifuge broadcaster for laravel &gt;= 5.3

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

[](#requirements)

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

##### If you use Centrifugo Server 1.6 you should use [LaraComponents/centrifuge-broadcaster](https://github.com/LaraComponents/centrifuge-broadcaster) package

[](#if-you-use-centrifugo-server-16-you-should-use-laracomponentscentrifuge-broadcaster-package)

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

[](#installation)

Require this package with composer:

```
composer require theardent/centrifuge-broadcaster
```

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

```
'providers' => [
    // ...
    TheArdent\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',
        'api_key'          => env('CENTRIFUGE_API_KEY'), // you api key
        '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_API_KEY=very-long-api-key
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://centrifugal.github.io/centrifugo/)

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

A simple example of using the client:

```
