PHP code example of forget-chuckie / swoole
1. Go to this page and download the library: Download forget-chuckie/swoole 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/ */
forget-chuckie / swoole example snippets
use Swoole\Server\Swoole;
use Swoole\Server\Callback\SwooleWebSocket;
$swoole = new Swoole([
'server_type' => 'ws',
'host' => '127.0.0.1',
'port' => 9502,
'work_mode' => SWOOLE_PROCESS,
'pid_path' => './masterPid/',//进程ID保存文件路径
'project_name' => 'sokcet',
'worker_num' => 4
]);
//这里设服务要回调的类。必须继承 Callback 下对应的服务类型。
$swoole->setClient($obj);
//服务启动
$swoole->run();