require_once 'vendor/autoload.php';//必定是未引入这个
wechatpay-guzzle-middleware 报错提示 class找不到<?php declare (strict_types = 1); namespace app\wechat\extend; use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use WechatPay\GuzzleMiddleware\Util\PemUtil; use WechatPay\GuzzleMiddleware\WechatPayMiddleware; class WechatPay { public function place($data) { $merchantKey=PemUtil::loadPrivateKey(app()->getRootPath().$this->merchantPrivateKey); $merchantCert=PemUtil::loadCertificate(app()->getRootPath().$this->wechatpayCertificate); $wechatpayMiddleware=WechatPayMiddleware::builder() ->withMerchant($this->merchantId,$this->merchantSerialNumber,$merchantKey) ->withWechatPay([$merchantCert]) ->build(); $stack=HandlerStack::create(); $stack->push($wechatpayMiddleware); $client=new Client(['handler'=>$stack]); try { // $resp = $client->request('GET', 'https://api.mch.weixin.qq.com/v3/...', [ // 注意替换为实际URL // 'headers' => [ 'Accept' => 'application/json' ] // ]); // // echo $resp->getStatusCode().' '.$resp->getReasonPhrase()."\n"; // echo $resp->getBody()."\n"; $data['appid']=$this->APPID; $data['mchid']=$this->merchantId; $data=json_encode($data); $resp = $client->request('POST', $this->place_url, [ 'json' => $data, 'headers' => [ 'Accept' => 'application/json' ] ]); $res['statusCode']=$resp->getStatusCode(); $res['reasonPhrase']=$resp->getReasonPhrase(); $res['body']=$resp->getBody(); return $res; } catch (\RangeException $e) { // 进行错误处理 echo $e->getMessage()."\n"; if ($e->hasResponse()) { echo $e->getResponse()->getStatusCode().' '.$e->getResponse()->getReasonPhrase()."\n"; echo $e->getResponse()->getBody(); } return; } } } #0 [0]Error in WechatPay.php line 26Class 'WechatPay\GuzzleMiddleware\Util\PemUtil' not found报错class找不到,这个问题怎么解决,使用的是thinkphp6
2021-09-17