xsites/laravel-socket.io

Laravel Socket.io broadcaster
1,441 9
Install
composer require xsites/laravel-socket.io
Latest Version:v0.1.0
PHP:>=5.6.4
License:MIT
Last Updated:May 2, 2016
Links: GitHub  ·  Packagist
Maintainer: xsites

Laravel Socket.io Broadcaster

Installation

Pull this package in through Composer.

    composer require xsites/laravel-socket.io

Laravel 5.* Integration

Add the service provider to your config/app.php file:


    'providers'  => array(

    //...
    Xsites\LaravelSocketIO\Providers\SocketIOServiceProvider::class,

),

Configuration

Add the broadcaster to your config/broadcasting.php file:


    // Set here the new broadcast connection
    'default' => 'socket-io',
    
    //...

    'connections' => [

        // Add additional connection for socket.io broadcaster
        'socket-io' => [
            'driver' => 'socket.io',
            'redis' => [
                //set the redis connection
                'connection' => 'default',
            ],
        ],
        //...

    ],

Usage

See the official documentation https://laravel.com/docs/5.1/events#broadcasting-events

Example

    
    class Test extends Event implements ShouldBroadcast
    {
        /**
         * @var array
         */
        public $data;
    
        /**
         * Create a new event instance.
         *
         * @param mixed $data
         */
        public function __construct($data)
        {
            $this->data = $data;
        }
    
        /**
         * Get the channels the event should be broadcast on.
         *
         * @return array
         */
        public function broadcastOn()
        {
            return ['test-channel-name'];
        }
    }
    
    ...
    //In your BLL
    Event::fire(new Test(['param1' => 'value'1]));
    //
    Event::fire(new Test(123));
    

Contact

Anton Pavlov

Related Packages

php-junior/laravel-video-chat

Laravel Video Chat using Socket.IO and WebRTC

18,237 815
moura137/laravel-elephantio

ElephantIO Service Provider for the Laravel PHP Framework

7,290 9
underthecocotree/laravel-chat

A chat module built for laravel using socket.io

43
php-tmdb/laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the...

53,312 160