这里写描述
如题当get请求中参数名包含secret时会报一个包冲突的错误
日志:
2023-04-08 07:34:21 pid:6796 Workerman[start.php] start in DEBUG mode
2023-04-08 07:34:37 pid:6803 Worker[6803] process terminated with ERROR: E_COMPILE_ERROR "Declaration of Symfony\Component\Cache\CacheItem::expiresAt(?DateTimeInterface $expiration): static must be compatible with PsrExt\Cache\CacheItemInterface::expiresAt($expiration) in /dota2helper/dota2server/vendor/symfony/cache/CacheItem.php on line 77"
2023-04-08 07:34:37 pid:6796 worker[webman:6803] exit with status 65280
有一点没搞明白,在本地虚拟机ubuntu中并未报此错误,同一套代码
{
"name": "workerman/webman",
"type": "project",
"keywords": [
"high performance",
"http service"
],
"homepage": "https://www.workerman.net",
"license": "MIT",
"description": "High performance HTTP Service Framework.",
"authors": [
{
"name": "walkor",
"email": "walkor@workerman.net",
"homepage": "https://www.workerman.net",
"role": "Developer"
}
],
"support": {
"email": "walkor@workerman.net",
"issues": "https://github.com/walkor/webman/issues",
"forum": "https://wenda.workerman.net/",
"wiki": "https://workerman.net/doc/webman",
"source": "https://github.com/walkor/webman"
},
"require": {
"php": ">=7.2",
"workerman/webman-framework": "^1.4.3",
"monolog/monolog": "^2.0",
"psr/container": "^1.1.1",
"illuminate/database": "^9.51",
"illuminate/pagination": "^9.51",
"illuminate/events": "^9.52",
"symfony/var-dumper": "^6.0",
"topthink/think-validate": "^2.0",
"jasongrimes/paginator": "^1.0.3",
"symfony/translation": "^6.0",
"intervention/image": "^2.7",
"vlucas/phpdotenv": "^5.5",
"workerman/crontab": "^1.0",
"teamones/response-code-msg": "^0.0.1",
"webman/console": "^1.2",
"webman/event": "^1.0",
"webman/admin": "^0.5.8",
"workerman/validation": "^3.0",
"thiagoalessio/tesseract_ocr": "^2.7",
"illuminate/redis": "^9.52",
"symfony/cache": "^6.0",
"yzh52521/webman-throttle": "^1.0",
"phpmailer/phpmailer": "^6.8"
},
"suggest": {
"ext-event": "For better performance. "
},
"autoload": {
"psr-4": {
"": "./",
"app\\": "./app",
"App\\": "./app",
"app\\View\\Components\\": "./app/view/components"
},
"psr-0" : {
"": "extend/"
},
"files": [
"./support/helpers.php"
]
},
"scripts": {
"post-package-install": [
"support\\Plugin::install"
],
"post-package-update": [
"support\\Plugin::install"
],
"pre-package-uninstall": [
"support\\Plugin::uninstall"
]
},
"require-dev": {
"phpunit/phpunit": "^9.6"
}
}
public function config(Request $request)
{
return json(['code' => self::SUCCESS, 'data' => time()]);
}
Centos7
Workerman version:4.1.6 PHP version:8.0.18 Event-Loop:\Workerman\Events\Event
不支持gif动图啊......
第三方库的问题
Symfony\Component\Cache\CacheItem
实现接口PsrExt\Cache\CacheItemInterface
的expiresAt
,但参数类型不一样。说明本地php版本和线上不一致。
比如本地是php7.x,composer安装的组件是基于php7.x的。然后你把vendor都提交到了线上,线上是php8.x,
但是组件还是php7.x的组件,导致不兼容,就报错了。
开发一大忌就是本地php版本与线上php版本不一致。
php版本完全一致,都是自己编译安装的
执行 php -v 确认下
确认过的都是PHP 8.0.18 NTS
执行
composer info
看下本地symfony/cache
版本和线上版本是不是一样。已对比,composer info一致
git推上去的,代码全部一致
webman默认使用 symfony/cache作为cache组件,我先卸载 symfony/cache试试,看起来是 symfony/cache的一个潜在bug
卸载symfony/cache后,问题消失,因为我的php版本比较低是8.0.18,symfony/cache在composer安装的时候提示不能安装最新的,是装了一个低版本的,这个低版本的在ubuntu中不会报错,但是在centos7中会报错,,只要php版本高装最新版或者用ubuntu应该都不会出现这个问题