这个自定义进程为何老提示Error: Class 'process\Workerman\Mqtt\Client' not found
namespace process;
use Workerman\Worker;
class MqttTask
{
public function onWorkerStart()
{
$mqtt = new Workerman\Mqtt\Client('mqtt://127.0.0.1:1883', array(
'debug' => true,
"username"=>"admin", "password"=>"u123",
));
$mqtt->onConnect = function($mqtt) {
$mqtt->subscribe('zipcodexpress/sub');
};
$mqtt->onMessage = function($topic, $content){
echo "topic:$topic content:$content\n";
};
$mqtt->connect();
}
}
没找到 Workerman\Mqtt\Client 这个类
改成 \Workerman\Mqtt\Client 试试
解决了谢谢,$mqtt = new \Workerman\Mqtt\Client这样写就可以了