PHP code example of xiaowu / laraswoole

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

    

xiaowu / laraswoole example snippets


    laravel:5.5\5.8
    php:>=7.2
    swoole:>=4.0

$xslt
define('LARAVEL_START', microtime(true));
;

define('ROOT_PATH',dirname(__DIR__));

(new \Laraswoole\App()) ->run($argv);

$xslt
return [
     'localhost'=>'',  // 本服务IP地址,访问的服务器地址
     'http'=>[
         'host'=>'0.0.0.0', // 指定监听的ip地址
         'port'=>9500,      // 监听的端口
         'set_config'=>[     // 服务运行时的参数
             'worker_num'=>2, // 全异步非阻塞服务器 worker_num配置为CPU核数的1-4倍即可
             'max_request'=>5000 // 最大请求数
             // 其他参数可以参考swoole文档
         ]
     ],
    'ws'=>[
    
    ]
];
$xslt
http服务:
    php public/run.php http:start
websocket服务: