https://github.com/walkor/workerman/issues/1128
https://github.com/walkor/workerman/pull/1129
上面的合并在window环境下会导致协程无法使用,没有修改代码之前使用fopen(__FILE__, 'r'),在windows下代码运行是可以正常运行的, 合并以后变成了fopen('php://memory', 'r'),会导致报错:arning: [Fatal error in R7] Uncaught ErrorException: stream_poll_one(): Cannot represent a stream of type MEMORY as a select()able descriptor in \vendor\workerman\workerman\src\Events\Swow.php:150

// process.php 协程配置代码
'my-coroutine' => [
'handler' => Http::class,
'listen' => 'http://0.0.0.0:8999',
'count' => 1,
'user' => '',
'group' => '',
'reusePort' => false,
'eventLoop' => Workerman\Events\Swow::class,
'context' => [],
'constructor' => [
'requestClass' => Request::class,
'logger' => Log::channel('default'),
'appPath' => app_path(),
'publicPath' => public_path()
]
]
// 合并之后的Worker.php代码
// 下面是合并的代码,将之前的fopen(__FILE__, 'r');修改成fopen('php://memory', 'r');
// Compatibility with the bug in Swow where the first request on Windows fails to trigger stream_select.
if (extension_loaded('swow')) {
Timer::delay(0.1 , function(){
$stream = fopen('php://memory', 'r');
static::$globalEvent->onReadable($stream, function($stream) {
static::$globalEvent->offReadable($stream);
});
});
}
windows环境下配置协程,启动就会报错
操作系统: win11
php版本: PHP 8.2.9NTS
workerman/webman 版本:
"workerman/webman-framework": "^2.1",
"workerman/workerman": "~v5.1",
"Webman-framework": v2.1.4
workerman 升级到 5.1.8
果然一切问题都在大佬掌控之中,升级以后可以了!谢谢