PHPackages                             mkiselev/yii2-broadcasting - 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. mkiselev/yii2-broadcasting

ActiveYii2-extension[HTTP &amp; Networking](/categories/http)

mkiselev/yii2-broadcasting
==========================

Websocket broadcasting module

0.0.2(8y ago)91924MITJavaScript

Since Jul 12Pushed 8y ago2 watchersCompare

[ Source](https://github.com/MKiselev/yii2-broadcasting)[ Packagist](https://packagist.org/packages/mkiselev/yii2-broadcasting)[ RSS](/packages/mkiselev-yii2-broadcasting/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Yii2-broadcasting
=================

[](#yii2-broadcasting)

Websocket broadcasting module

[![Latest Stable Version](https://camo.githubusercontent.com/a39e5510227c6d7a7596d697dd1f43a562fa4fca105caa859505d52e2504c051/68747470733a2f2f706f7365722e707567782e6f72672f6d6b6973656c65762f796969322d62726f616463617374696e672f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/mkiselev/yii2-broadcasting)[![Total Downloads](https://camo.githubusercontent.com/f6cf88d34c2e09d596fa512734ac5a36f847767f6d5210a5465eab22bf0e4e2a/68747470733a2f2f706f7365722e707567782e6f72672f6d6b6973656c65762f796969322d62726f616463617374696e672f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/mkiselev/yii2-broadcasting)[![Latest Unstable Version](https://camo.githubusercontent.com/504bd5ee3fa908cd1e1f37d89f101ced4d7c65b15056a1ee107ad3f0482a3782/68747470733a2f2f706f7365722e707567782e6f72672f6d6b6973656c65762f796969322d62726f616463617374696e672f762f756e737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/mkiselev/yii2-broadcasting)[![License](https://camo.githubusercontent.com/e1f5b0557c8e871a52c147fd408efe48c1f423179585cf85c4ae826c4c063d02/68747470733a2f2f706f7365722e707567782e6f72672f6d6b6973656c65762f796969322d62726f616463617374696e672f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/mkiselev/yii2-broadcasting)[![Monthly Downloads](https://camo.githubusercontent.com/cc5d8644282f92fe9442e439be0b7fb3054be1ce5a1859900c5876c99407b5fc/68747470733a2f2f706f7365722e707567782e6f72672f6d6b6973656c65762f796969322d62726f616463617374696e672f642f6d6f6e74686c793f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/mkiselev/yii2-broadcasting)

This module is made under inspiration of laravel echo and compatible with libraries.

There are several broadcast tools available for your choice:

1. [NullBroadcaster](broadcasters/NullBroadcaster.php) Doing nothing, just a stub
2. [LogBroadcaster](broadcasters/LogBroadcaster.php) Broadcast events to application log
3. [RedisBroadcaster](broadcasters/RedisBroadcaster.php) Broadcast by Redis using Pub/Sub feature (required [yii2-redis](https://github.com/yiisoft/yii2-redis))
4. RatchetBroadcaster (coming soon...)
5. PusherBroadcaster Broadcast by using pusher.com (coming soon...)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require --prefer-dist mkiselev/yii2-broadcasting "*"

```

or add

```
"mkiselev/yii2-broadcasting": "*"

```

to the require section of your `composer.json` file.

Application configuration
-------------------------

[](#application-configuration)

Configure module for use some broadcaster and configure channels auth callbacks:

```
'bootstrap' => ['broadcasting'],
'modules' => [
    'broadcasting' => [
        'class' => \mkiselev\broadcasting\Module::class,
        'broadcaster' => [
            'class' => \mkiselev\broadcasting\broadcasters\RedisBroadcaster::class,
            // By default will be used redis application component, but you can configure as you want
            'redis' => [
                'class' => \yii\redis\Connection::class,
            ],
            // Configure auth callback for private and presitance chanells
            'channels' => [
                'signal' => function (\yii\web\User $user) {
                    return $user->can('something');
                },
            ],
        ],
    ],
],
```

Socket.io server configuration
------------------------------

[](#socketio-server-configuration)

This module is compilable with [laravel-echo-server](https://github.com/tlaverdure/laravel-echo-server)

Please follow to laravel-echo-server instructions to install and run them.

Usage
-----

[](#usage)

### Server side

[](#server-side)

Write your event extended by \\mkiselev\\broadcasting\\events\\BroadcastEvent like this:

```
