App\Config\YlyConfig是在MighPrinterService这个类中引入的
请问各位大佬 这个问题要怎么处理 感谢?
<?php
require_once __DIR__ . '/vendor/autoload.php';
/**
* xtn自动启用异步消息
*/
use Common\Services\MighPrinterService;
use Workerman\RedisQueue\Client;
use Workerman\Worker;
//require_once 'vendor/autoload.php';
//require 'Application/Common/Services/MighPrinterService.class.php';
$worker = new Worker();
$worker->onWorkerStart = function () {
$client = new Client('redis://127.0.0.1:6379');
// 订阅printer
$client->subscribe('printer', function ($data) {
(new MighPrinterService())->print($data['content'], $data['shopId'], $data['printer']);
var_export($data);
});
// 消费失败触发的回调(可选)
$client->onConsumeFailure(function (\Throwable $exception, $package) {
echo "队列 " . $package['queue'] . " 消费失败\n";
echo $exception->getMessage(), "\n";
var_export($package);
});
};
Worker::runAll();
{
"require": {
"phpmailer/phpmailer": "^6.9",
"firebase/php-jwt": "^6.10",
"paypal/paypal-server-sdk": "^0.6.1",
"guzzlehttp/guzzle": "^7.9",
"workerman/workerman": "^4.1",
"workerman/redis-queue": "^1.2"
},
"autoload": {
"psr-4": {
"": "./"
}
}
}
https://www.workerman.net/doc/workerman/faq/autoload.html
感谢大佬解答
大佬好 按照文档还是不行 项目是tp3.2我在tp中安装了 workerman/workerman和workerman/redis-queue 我补充了下代码 麻烦再刚我看下 感谢
tp3.2 我也不熟悉,不知道它的类是否支持composer自动加载
支持的 因为我可以正常调用的 phpmailer/phpmailer和firebase/php-jwt 只是subscribe我无法调用MighPrinterService 如果不在subscribe可以正常调用
phpmailer/phpmailer 这些不属于tp,都支持composer加载
好的 大佬 非常谢谢 目前已经处理好了