yansongda / pay

可能是我用过的最优雅的 Alipay/WeChat/Douyin/Unipay/江苏银行 的支付 SDK 扩展包了
http://pay.yansongda.cn
MIT License
5.04k stars 1.03k forks source link

在think-swoole扩展中 服务无法注入。一直报这个错误。下文 #673

Closed weilewantieba closed 2 years ago

weilewantieba commented 2 years ago

包版本号

3.1.0

问题描述

thinkphp6+thinkswoole使用的时候。一直无法使用。我看了源码是因为服务无法注入还是什么原因导致。在this->register的时候会爆出错误

你的代码

    $result = Pay::alipay($this->config)->web([
        'out_trade_no' => ''.time(),
        'total_amount' => '0.01',
        'subject' => 'yansongda 测试 - 1',
    ]);

报错详情

syntax error, unexpected token \")\";\/www\/wwwroot\/erp-agent-platforme\/api\/vendor\/symfony\/event-dispatcher\/EventDispatcher.php:270

composer版本

    "yansongda/pay": "^3.1",
    "php-di/php-di": "^6.4",
    "guzzlehttp/guzzle": "^7.0"

sdk 日志

nginx/apache 日志

涉及到 异步通知、同步通知 的问题,请贴出来

weilewantieba commented 2 years ago

config文件配置是没有问题。对了很多次了

yansongda commented 2 years ago

php 版本多少?

然后看看弄个最小的复现 demo 出来吧

weilewantieba commented 2 years ago

PHP 8.0.20 demo代码已经贴出来了。thinkphp6+ think-swoole $result = Pay::alipay($this->config)->web([ 'out_trade_no' => ''.time(), 'total_amount' => '0.01', 'subject' => 'yansongda 测试 - 1', ]);

yansongda commented 2 years ago

composer.json 里的呢

weilewantieba commented 2 years ago

{ "name": "topthink/think", "description": "the new thinkphp framework", "type": "project", "keywords": [ "framework", "thinkphp", "ORM" ], "homepage": "http://thinkphp.cn/", "license": "Apache-2.0", "authors": [ { "name": "liu21st", "email": "liu21st@gmail.com" }, { "name": "yunwuxin", "email": "448901948@qq.com" } ], "require": { "php": ">=7.2.5", "topthink/framework": "^6.0.0", "topthink/think-orm": "^2.0", "topthink/think-swoole": "^4.0", "hg/apidoc": "^3.1", "d-os/jwt": "^1.6", "alibabacloud/darabonba-openapi": "^0.2.5", "yuchl/aliyun-dy-sdk-lite": "^1.0", "overtrue/wechat": "~5.0", "overtrue/pinyin": "~4.0", "phpoffice/phpspreadsheet": "^1.14", "weilewantieba/1688openapi": "dev-master", "pda/pheanstalk": "^4.0", "yansongda/pay": "~3.1.0", "php-di/php-di": "^6.4" }, "require-dev": { "symfony/var-dumper": "^4.2", "topthink/think-trace":"^1.0" }, "autoload": { "psr-4": { "app\": "app" }, "psr-0": { "": "extend/" } }, "config": { "preferred-install": "dist", "allow-plugins": { "easywechat-composer/easywechat-composer": true } }, "scripts": { "post-autoload-dump": [ "@php think service:discover", "@php think vendor:publish" ] } }

weilewantieba commented 2 years ago

我是thinkphp6 + think-swoole得composer 来运行的。

weilewantieba commented 2 years ago

"code":0,"message":"No entry or class found for 'alipay' 偶尔也会报这个错误

yansongda commented 2 years ago

PHP 8.0.20 demo代码已经贴出来了。

你这不对吧,都安装不上,你弄个最小的 demo repo 出来吧。

我感觉你这是环境问题,或者哪个包里的 symfony/event-dispatcher 冲突了

截屏2022-09-07 09 53 50

weilewantieba commented 2 years ago

这个包你要忽略掉来装。这个jwt包是我自己的 composer install --ignore-platform-reqs 我没有更新最新包。你把jwt忽略掉

weilewantieba commented 2 years ago

你把jwt包弄掉 应该是没问题。 "d-os/jwt": "^1.6", 这个包你可以去除掉

yansongda commented 2 years ago

你弄个最小的能复现的项目 repo 吧

weilewantieba commented 2 years ago

已经排查 和ewasywechat这个包有冲突 "overtrue/wechat": "~5.0",

yansongda commented 2 years ago

这个包不冲突的,无论是最新版还是历史版本,你检查你自己的环境吧

weilewantieba commented 2 years ago

已经排查 和ewasywechat这个包有冲突 "overtrue/wechat": "~5.0", 我就单独去了这个包 就不会报错了。。