在 Swoole
官网增加了 在线运行 的按钮,可以直接运行首页提供的一些示例代码,当然也可以手动输出一些 PHP
代码进行测试。
可以访问 Swoole 官网首页进行测试使用:https://www.swoole.com/
目前还处于测试阶段,有遇到 BUG
可以向识沃科技客服反馈或交流群中反馈。
在未正式发布时,对于一些新特性和功能发布过文章进行说明,所以重复的在此就不再赘述,可以查看:
对于其他的一些修改进行说明:
在之前的版本中,如果使用disable_functions
将方法进行了禁用,在 HOOK
之后依旧能正常调用。
如下代码:
var_dump(`ls`);
Swoole\Coroutine\run(function () {
var_dump(`ls`);
});
保存到test.php
中,命令行使用php -d disable_functions=shell_exec test.php
执行
之前的版本输出为:
PHP Warning: shell_exec() has been disabled for security reasons in /Users/lufei/Swoole/test.php on line 3
NULL
string(11) "swoole.php
"
而升级 v4.7.0
之后,行为和 HOOK 前一致。
PHP Warning: shell_exec() has been disabled for security reasons in /Users/lufei/Swoole/test.php on line 3
NULL
PHP Warning: shell_exec() has been disabled for security reasons in /Users/lufei/Swoole/test.php on line 6
NULL
Coroutine\go()
方法增加了返回值之前的版本中使用 Coroutine\go()
方法不会返回协程 ID,从v4.7.0
中开始增加了返回值,返回当前协程 ID。
use Swoole\Coroutine\System;
use function Swoole\Coroutine\run;
use function Swoole\Coroutine\go;
run(function () {
$cid = go(function() {
System::sleep(0.001);
});
var_dump($cid);
});
Cygwin
环境下的构建从v4.7.0
版本开始,可以从 GitHub release 中获取到该版本的 Cygwin
版本压缩包进行使用。
下面是完整的更新日志:
Process\Pool::detach()
方法 (#4221) (@matyhtf)Server
支持 onDisconnect
回调函数 (#4230) (@matyhtf)Coroutine::cancel()
和 Coroutine::isCanceled()
方法 (#4247) (#4249) (@matyhtf)Http\Client
支持 http_compression
和 body_decompression
选项 (#4299) (@matyhtf)prepare
时字段严格类型 (#4238) (@Yurunsoft)c-ares
库 (#4275) (@matyhtf)Server
支持在多端口监听时给不同的端口配置心跳检测时间 (#4290) (@matyhtf)Server
的 dispatch_mode
支持 SWOOLE_DISPATCH_CO_CONN_LB
和 SWOOLE_DISPATCH_CO_REQ_LB
模式 (#4318) (@matyhtf)ConnectionPool::get()
支持 timeout
参数 (swoole/library#108) (@leocavalcante)CURLOPT_PRIVATE
选项 (swoole/library#112) (@sy-records)PDOStatementProxy::setFetchMode()
方法的函数声明 (swoole/library#109) (@yespire)Atomic\Long
在 M1 芯片下的问题 (e6fae2e) (@matyhtf)Coroutine\go()
丢失返回值的问题 (swoole/library@1ed49db) (@matyhtf)StringObject
返回值类型问题 (swoole/library#111) (swoole/library#113) (@leocavalcante) (@sy-records)Cygwin
环境下的构建 (#4222) (@sy-records)alpine 3.13
和 3.14
的编译测试 (#4309) (@limingxinleo)