Symfony\Component\Translation\TranslatorInterface::setLocale($locale) 声明

Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale)

我在 CPanel 上上传了一个 laravel 项目,但出现此错误

Symfony\Component\Translation\TranslatorInterface::setLocale($locale) 的声明必须与 Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)

兼容

该项目在本地主机上运行良好,我的问题出在 CPanel 中。

我的laravel项目的版本是5.8.36

看起来您 运行 composer 更新了与用于执行应用程序的版本不同的 PHP 版本。

解决方案是执行以下操作:-

Symfony/translation-contracts/composer.json编辑

"require": {
        "php": "^7.2.9"
},

"require": {
        "php": "^7.1.3"
},

然后将 symfony/translation-contracts: "^1.1.6" 添加到 project/composer.json 之后 运行 作曲家更新它应该可以工作:)