PHPackages                             jonh-wu/laracent - 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. jonh-wu/laracent

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

jonh-wu/laracent
================

Centrifugo broadcaster for laravel &gt;= 5.7 and Centrifugo &gt;= 2.1.0

013PHP

Since Oct 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/jonhwu/laracent)[ Packagist](https://packagist.org/packages/jonh-wu/laracent)[ RSS](/packages/jonh-wu-laracent/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

LARAvel + CENTrifugo = Laracent
===============================

[](#laravel--centrifugo--laracent)

Centrifugo broadcast driver for Laravel 5+
------------------------------------------

[](#centrifugo-broadcast-driver-for-laravel-5)

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

[](#introduction)

Centrifugo broadcaster for laravel &gt;= 5.7 is fork of [centrifuge-broadcaster](https://github.com/LaraComponents/centrifuge-broadcaster), based on:

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

Changenotes
-----------

[](#changenotes)

- predis/predis removed from dependencies
- Removed all code, related to Redis
- Updated public functions code in accordance with new version of Centrifugo API

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

[](#requirements)

- PHP 7.2.12+ or newer
- Laravel 5.7 or newer
- Centrifugo Server 2.1.0 or newer (see [here](https://github.com/centrifugal/centrifugo))

Dependencies
------------

[](#dependencies)

- guzzlehttp/guzzle

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

[](#installation)

Require this package with composer:

```
composer require jonh-wu/laracent
```

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

```
'providers' => [
    // ...
    JonhWu\Laracent\LaracentServiceProvider::class,

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

Open your config/broadcasting.php and add new connection like this:

```
    'centrifugo' => [
        'driver' => 'centrifugo',
        'secret'  => env('CENTRIFUGO_SECRET'),
        'apikey'  => env('CENTRIFUGO_APIKEY'),
        'url'     => env('CENTRIFUGO_URL', 'http://localhost:8000'), // centrifugo api url
        'verify'  => env('CENTRIFUGO_VERIFY', false), // Verify host ssl if centrifugo uses this
        'ssl_key' => env('CENTRIFUGO_SSL_KEY', null), // Self-Signed SSl Key for Host (require verify=true)
    ],
```

Also you should add these two lines to your .env file:

```
CENTRIFUGO_SECRET=very-long-secret-key-from-centrifugo-config
CENTRIFUGO_APIKEY=long-secret-apikey-from-centrifugo-config

```

These lines are optional:

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

```

Don't forget to change `BROADCAST_DRIVER` setting in .env file!

```
BROADCAST_DRIVER=centrifugo

```

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

[](#basic-usage)

To configure Centrifugo server, read [official documentation](https://centrifugal.github.io/centrifugo/)

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

A simple client usage example:

```
