laravel6.52 报TranslatorInterface类的错误

报错:
image.png

Symfony\Component\Debug\Exception\FatalErrorException
Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale) 
vendor\symfony\translation\TranslatorInterface.php:24

image.png

使用

composer dump-autoload
php artisan cache:clear
php artisan config:clear
php artisan clear-compiled

都报此错误

阅读 4.9k
1 个回答

我也遇到同样的问题了 你的解决了吗
我的解决方案,在composer.json里面加入

"symfony/translation-contracts": "^1.1.6"

"require": {
    "php": "^7.2",
    "fideloper/proxy": "^4.0",
    "laravel/framework": "^6.2",
    "laravel/tinker": "^1.0",
},
"require": {
    "php": "^7.2",
    "fideloper/proxy": "^4.0",
    "laravel/framework": "^6.2",
    "laravel/tinker": "^1.0",
    "symfony/translation-contracts": "^1.1.6",
},

之后执行命令

composer update
composer dump-autoload

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题