hyperf 接入 easywechat
easyweacht是基于fpm模式开发的
不能直接在hyperf或者其他的swoole框架中直接食用
//实例化公众号 小程序 支付同理
$app = Factory::officialAccount(config('officialAccount'));
$config = $app['config']->get('http', []);
$config['handler'] = di()->get(HandlerStackFactory::class)->create();
$app->rebind('http_client', new Client($config));
// 重写 Handler
$app['guzzle_handler'] = new CoroutineHandler();
AbstractProvider::setGuzzleOptions([
'http_errors' => false,
'handler' => HandlerStack::create(new CoroutineHandler())
]);
//重写缓存
$app['cache'] = di()->get(CacheInterface::class);
//获取回调通知
//可以直接修改easywehcat的request 或者直接使用hyperf的 request获取body自行解析xml
//重写easywechat的request
// $get = $request->getQueryParams();
//
// $post = $request->getParsedBody();
//
// $cookie = $request->getCookieParams();
//
// $files = $request->getUploadedFiles();
//
// $server = $request->getServerParams();
//
// $xml = $request->getBody()->getContents();
//
// $app['request'] = new Request($get, $post, [], $cookie, $files, $server, $xml);
Hyperf 官网有相关的文档,可以直接根据文档的方案来使用 https://www.hyperf.wiki/#/zh-cn/sdks/wecha...