PHP code example of xiaochengfu / swoole-websocket

1. Go to this page and download the library: Download xiaochengfu/swoole-websocket 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/ */

    

xiaochengfu / swoole-websocket example snippets


composer 

$setting = config('params.swoole');//框架获取配置的方法,各有不同

$swoole = new SwooleService($setting);
$swoole->serviceStart();

$swoole = new \xiaochengfu\swoole\Swoole(config('params.swoole'));
$swoole->pushMsg(1,['hello','world']);

//注意pushMsg($fd,$data)
//fd 这里可用刚连接的客户端1
//data 类型为数组