[已解决] webman http-client 同步返回null

lsmir2

问题描述

截图

程序代码或配置

    public function httptest(): string
    {
        $url='https://baidu.com';
        $http = new \Workerman\Http\Client();
        $response=$http->get($url);
        return $response->getBody()->getContents();
    }

操作系统环境及workerman/webman等具体版本

macos 14.7 (23H124)

php -v
Cannot load Xdebug - it was already loaded
PHP 8.3.17 (cli) (built: Feb 21 2025 19:28:19) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.17, Copyright (c) Zend Technologies
with Xdebug v3.4.1, Copyright (c) 2002-2025, by Derick Rethans

composer
截图

composer切到华为云进行降级
截图
截图

revolt/event-loop 是1.0.6 $response 是有值的
等大佬解惑..

162 1 1
1个回答

workerman 5.1开始所有协程需要手动开启,包括Fiber。

$worker->eventLoop = Workerman\Events\Fiber::calss;
  • lsmir2 3天前
    webman
    'eventLoop' => class_exists(Workerman\Events\Fiber::class) ? Workerman\Events\Fiber::class : ''
    线上 workerman 5.0.1 本地 5.1
×
🔝