PHP code example of vluzrmos / lumen-socketio

1. Go to this page and download the library: Download vluzrmos/lumen-socketio library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vluzrmos / lumen-socketio example snippets

 
$app->register('Vluzrmos\Socketio\SocketioServiceProvider');

$app->get('/publish', function() {
    publish('channel', 'awesome-event', 'An message');
    publish('channel', 'awesome-event', ['message' => 'An message', 'user' => \App\User::first()]);
});


//or, in your controller or some else method (using Dependency Injection)

public function publishSomethingAwesome(\Vluzrmos\Socketio\Contracts\Broadcast $broadcast){
    $broadcast->publish('channel', 'awesome-event', 'An message');
    
    // or just use the helper without inject \Vluzrmos\Socketio\Contracts\Broadcast
    
    publish('channel', 'awesome-event', 'An message');
}

bash
php artisan serve