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

ActiveLibrary

kot13/laracent
==============

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

1.0.0(7y ago)095MITPHPPHP &gt;=7.2.12

Since Feb 18Pushed 5y agoCompare

[ Source](https://github.com/kot13/laracent)[ Packagist](https://packagist.org/packages/kot13/laracent)[ Docs](https://github.com/AlexHnydiuk/laracent)[ RSS](/packages/kot13-laracent/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (2)Used By (0)

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

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

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

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

[![Build Status](https://camo.githubusercontent.com/c265937f5d07c6de447e7d84cfc92ae5eba8ab99a742231f2c10f67f52e37d07/68747470733a2f2f7472617669732d63692e6f72672f416c6578486e796469756b2f6c61726163656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/AlexHnydiuk/laracent)[![Latest Version](https://camo.githubusercontent.com/841687a725fb230e18ccf278286cf457b01899fe853edcd147f8f37f084f8d2c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f416c6578486e796469756b2f6c61726163656e742e7376673f7374796c653d666c61742d737175617265)](https://github.com/AlexHnydiuk/laracent/releases)[![Quality Score](https://camo.githubusercontent.com/476d675445696be4567994c24d5621638eae9850b74b436423448d7f99754ddc/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f416c6578486e796469756b2f6c61726163656e742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/AlexHnydiuk/laracent)[![StyleCI](https://camo.githubusercontent.com/736afb71b9baaaaade8631c348b8ea4054ec658b13ea06a319b5bb8aceb6d2d9/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137313132393938362f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/171129986)[![Total Downloads](https://camo.githubusercontent.com/e831c34a68bd87214b31a3bd78ecc4eb0a979380cbbbb162eca5db0dba7735fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c65782d686e796469756b2f6c61726163656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alex-hnydiuk/laracent)[![Software License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/AlexHnydiuk/laracent/blob/master/LICENSE)

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 alex-hnydiuk/laracent
```

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

```
'providers' => [
    // ...
    AlexHnydiuk\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:

```
