Swoole简要:
它是PHP的异步、并行、高性能网络通信引擎,支持TCP长连接,Websocket,Mqtt等协议。广泛用于手机app、手游服务端、网络游戏服务器、聊天室、硬件通讯、智能家居、车联网、物联网等领域的开发。
Pecl安装Swoole步骤:
进入PHP扩展官网:http://pecl.php.net/package/swoole。
找到自己需要安装的版本,依照 4.4.26 版本为例,然后执行 pecl install http://pecl.php.net/get/swoole-4.4.26.tgz,进入自动编译安装。
Swoole安装选项说明:
enable sockets supports? [no] : 启用套接字支持?[否]
enable openssl support? [no] : 启用OpenSSL支持?[否]
enable http2 support? [no] : 启用HTTP2支持?[否]
enable mysqlnd support? [no] : 启用mysqlnd支持?[否]
enable postgresql coroutine client support? [no] : 启用PostgreSQL协程客户端支持?[否]
查询一下是否安装成功,执行 php --ri swoole
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.4.26
Built => Jun 4 2021 12:57:00
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1g FIPS 21 Apr 2020
http2 => enabled
pcre => enabled
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608