在easyswoole 3.x版本 控制器使用协程报错,提示未定义go()

class Index extends Controller
{
    function index()
    {
        $file = EASYSWOOLE_ROOT.'/vendor/easyswoole/easyswoole/src/Resource/Http/welcome.html';
        if(!is_file($file)){
            $file = EASYSWOOLE_ROOT.'/src/Resource/Http/welcome.html';
        }
        go(function(){
            co::sleep(1);
            echo 1;
        });
        $this->response()->write(file_get_contents($file));
    }
DEBUG : [Call to undefined function App\HttpController\go() at file:/wwwroot/App/HttpController/Index.php line:18]
阅读 3.6k
2 个回答
新手上路,请多包涵

已解决 是短别名未开启的原因 开启就好了

新手上路,请多包涵

开启swoole里面的短别名swoole.use_shortname=On

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进