簡體   English   中英

Symfony\Component\Debug\Exception\FatalErrorException laravel 錯誤

[英]Symfony\Component\Debug\Exception\FatalErrorException laravel Error

我的新 Laravel 項目出現此錯誤。 我試圖在全新安裝后運行。

Symfony\Component\Translation\TranslatorInterface::setLocale($locale) 的聲明必須與 Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale) 兼容

在我的服務器上,以下是配置:

PHP 7.1.26-1+ubuntu14.04.1+deb.sury.org+1 Laravel 框架 5.7.28

解決方案:composer.json中添加"symfony/translation": "4.3.8"如下

"require": {
     ...
     "symfony/translation": "4.3.8",
}

接着

composer update

或者(如果服務器不推薦php版本)

作曲家更新--ignore-platform-reqs

composer update (symfony\translation v4.3.8 => v4.4.0)后,我在 PHP 7.2.3 上遇到了同樣的錯誤。

我在 composer.json 中用"symfony/translation": "4.3.8"

硬編輯供應商文件是個壞主意。

--

編輯:

Symfony doc says Install PHP 7.2.5 or higher , so if you don't want to add this restriction into your composer.json file, you can upgrade your PHP version to 7.2.5+ (check others libraries compatibility first).

我今天遇到了同樣的錯誤,我通過一些編輯解決了它。 只需這樣做:
導航

供應商/symfony/translation-contracts/LocaleAwareInteface.php

並從setLocale() function 中刪除string關鍵字。

如果您在此之后收到此錯誤:

Symfony\Component\Translation\Translator::trans($id, array $parameters = Array, $domain = NULL, $locale = NULL) 的聲明必須與 Symfony\Contracts\Translation\TranslatorInterface::trans(string $id) 兼容, 數組 $parameters = 數組, ?string $domain = NULL, ?string $locale = NULL)

只需導航到:

供應商/symfony/translation-contracts/TranslatorInterface.php

並從trans() function 中刪除所有string關鍵字

- 編輯 -

如果您不想編輯供應商文件,可以使用:打開您的 composer.json 文件,並將其添加到"require"

“symfony/翻譯”:“4.3.8”,

然后打開你的終端並輸入:

作曲家更新

這不是一個錯誤。

最新版本的 symfony 軟件包要求 PHP 版本至少為 7.2.5

將 PHP 版本更改為 7.2.5 或更高版本,它應該可以工作。

在我的服務器上,以下是配置:

PHP 7.2 Laravel Framework 6.*

解決方案:在composer.json中添加“symfony/translation”:“4.3.8”如下

"require": {
     ...
     "symfony/translation": "4.3.8",
}

接着

composer update

將我的 PHP 版本更新到 7.3 對我有用。

“symfony/translation”:composer.json 中的“4.3.8”,它幫助了我。!!非常感謝。

在漫游谷歌這么久之后,我找到了解決這個問題的簡單方法。 如果它可以幫助某人。 將您的 PHP 版本升級到 7.2 或更高版本

 1. sudo a2dismod phpX(X is less than 7.2 version) 
 2. sudo a2enmod php7.2(could be greater than or equal to 7.2)
 3. service apache2 restart

遵循這些步驟應該可以幫助您擺脫這個問題

更新您的 PHP 版本。 這通常是由於使用不同版本的 PHP 運行composer update導致的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM