Thinkphp6提示: Command “swoole“ is not defined 的解决方法
2022-11-24 11:10:29
246
{{single.collect_count}}

在Thinkphp6中已经使用如下命令安装好swoole扩展,在php --ri swoole,phpinfo()页面都可以查看到swoole的信息

composer require topthink/think-swoole

但是在运行

php think swoole

提示错误: Command "swoole" is not defined

遇到这个问题,如何解决?

1.运行

php think 

查看Available commands列表中是否有swoole,如果没有,肯定是无法运行成功的。

  OssStatic         将静态资源上传到oss上  build             Build App Dirs  clear             Clear runtime file  curd              一键curd命令服务  help              Displays help for a command  list              Lists commands  node              系统节点刷新服务  run               PHP Built-in Server for ThinkPHP  version           show thinkphp framework version

在项目中找到console.php文件,添加swoole

<?php// +----------------------------------------------------------------------// | 控制台配置// +----------------------------------------------------------------------return [// 指令定义'commands' => ['curd'=> 'app\common\command\Curd','node'=> 'app\common\command\Node','OssStatic' => 'app\common\command\OssStatic','swoole' => 'think\swoole\command\Server',],];

再次运行php think ,就可以看到已经有swoole参数

运行 php think swoole,swoole可以运行

 

不过呢,报了新的错误,这就是另外新的问题,另寻解决方法。

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}