PHP code example of lackone / laravel-phpsocket-io

1. Go to this page and download the library: Download lackone/laravel-phpsocket-io 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/ */

    

lackone / laravel-phpsocket-io example snippets


'providers' => [
    // ...
    Lackone\LaravelPhpsocketIo\Providers\PhpSocketIOServiceProvider::class,
];

php artisan vendor:publish --provider="Lackone\LaravelPhpsocketIo\Providers\PhpSocketIOServiceProvider"

class Msg extends DefaultMsg
{
    //方法名就是 $socket->on('方法名', function() {})
    public function test($msg) 
    {
        dump($msg);
        //消息处理
        
        $this->global['sockets'][$this->socket_id]->emit('message', date('YmdHis'));
    }
}

php artisan ps default start