thinkphp5.1+workerman/mqtt允许报错

danbai

问题描述

thinkphp5.1+workerman/mqtt允许报错
这里详细描述问题
执行 php think worker:server 运行报错

程序代码

<?php
namespace app\http\controller;
use think\worker\Server;
use Workerman\Worker;
use Workerman\Lib\Timer;
class Mqtt extends Server
{
    public function onWorkerStart($worker)
    {
        $mqtt = new \workerman\Mqtt\Client('mqtt://8.141.13.241:1883');
        $mqtt->onConnect = function($connect) {
            $connect->subscribe('text');
        };
        $mqtt->onMessage = function($topic, $content){
            echo '[订阅者][收到主题]:' . $topic . PHP_EOL;
            echo '[订阅者][收到内容]:' . $content . PHP_EOL;
        };
        $mqtt->connect();
        Worker::runAll();
    }
}

报错信息

[root@iZbp1j77****gp68uqmwZ xbkj.51.toponet.cn]# php think worker:server
Error: Class 'workerman\Mqtt\Client' not found in /www/wwwroot/xbkj.51.toponet.cn/application/http/controller/Mqtt.php:17
Stack trace:
#0 /www/wwwroot/xbkj.51.toponet.cn/vendor/workerman/workerman/Worker.php(2395): app\http\controller\Mqtt->onWorkerStart()
#1 /www/wwwroot/xbkj.51.toponet.cn/vendor/workerman/workerman/Worker.php(1543): Workerman\Worker->run()
#2 /www/wwwroot/xbkj.51.toponet.cn/vendor/workerman/workerman/Worker.php(1373): Workerman\Worker::forkOneWorkerForLinux()
#3 /www/wwwroot/xbkj.51.toponet.cn/vendor/workerman/workerman/Worker.php(1347): Workerman\Worker::forkWorkersForLinux()
#4 /www/wwwroot/xbkj.51.toponet.cn/vendor/workerman/workerman/Worker.php(1677): Workerman\Worker::forkWorkers()
#5 /www/wwwroot/xbkj.51.toponet.cn/vendor/workerman/workerman/Worker.php(1626): Workerman\Worker::monitorWorkersForLinux()
#6 /www/wwwroot/xbkj.51.toponet.cn/vendor/workerman/workerman/Worker.php(549): Workerman\Worker::monitorWorkers()
#7 /www/wwwroot/xbkj.51.toponet.cn/vendor/topthink/think-worker/src/command/Server.php(75): Workerman\Worker::runAll()
#8 /www/wwwroot/xbkj.51.toponet.cn/thinkphp/library/think/console/Command.php(175): think\worker\command\Server->execute()
#9 /www/wwwroot/xbkj.51.toponet.cn/thinkphp/library/think/Console.php(675): think\console\Command->run()
#10 /www/wwwroot/xbkj.51.toponet.cn/thinkphp/library/think/Console.php(261): think\Console->doRunCommand()
#11 /www/wwwroot/xbkj.51.toponet.cn/thinkphp/library/think/Console.php(198): think\Console->doRun()
#12 /www/wwwroot/xbkj.51.toponet.cn/thinkphp/library/think/Console.php(115): think\Console->run()
#13 /www/wwwroot/xbkj.51.toponet.cn/think(22): think\Console::init()
#14 {main}

截图报错信息里报错文件相关代码

这里粘贴截图

截图

348 1 0
1个回答

six

按照文档是 Workerman\Mqtt\Client 大写W

×
🔝