[英]Symfony\Component\Debug\Exception\FatalErrorException laravel Error
I am getting this error on my new Laravel project.我的新 Laravel 项目出现此错误。 I am trying to run after a fresh installation.
我试图在全新安装后运行。
Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)
Symfony\Component\Translation\TranslatorInterface::setLocale($locale) 的声明必须与 Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale) 兼容
On my server following were configurations:在我的服务器上,以下是配置:
PHP 7.1.26-1+ubuntu14.04.1+deb.sury.org+1 Laravel Framework 5.7.28 PHP 7.1.26-1+ubuntu14.04.1+deb.sury.org+1 Laravel 框架 5.7.28
Solution: Added "symfony/translation": "4.3.8"
in composer.json as follows解决方案:在composer.json中添加
"symfony/translation": "4.3.8"
如下
"require": {
...
"symfony/translation": "4.3.8",
}
and then接着
composer update
composer update --ignore-platform-reqs作曲家更新--ignore-platform-reqs
I got the same error on PHP 7.2.3 after composer update
(symfony\translation v4.3.8 => v4.4.0).在
composer update
(symfony\translation v4.3.8 => v4.4.0)后,我在 PHP 7.2.3 上遇到了同样的错误。
I solved this issue with "symfony/translation": "4.3.8"
in my composer.json.我在 composer.json 中用
"symfony/translation": "4.3.8"
。
It's a bad idea to hard edit vendors files.硬编辑供应商文件是个坏主意。
-- --
Edit:编辑:
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 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).
I got the same error today and I solved it with a little editing.我今天遇到了同样的错误,我通过一些编辑解决了它。 Just do this:
只需这样做:
Navigate to导航
vendor/symfony/translation-contracts/LocaleAwareInteface.php供应商/symfony/translation-contracts/LocaleAwareInteface.php
and delete string
keyword from the setLocale()
function.并从
setLocale()
function 中删除string
关键字。
If you get this error after this:如果您在此之后收到此错误:
Declaration of Symfony\Component\Translation\Translator::trans($id, array $parameters = Array, $domain = NULL, $locale = NULL) must be compatible with Symfony\Contracts\Translation\TranslatorInterface::trans(string $id, array $parameters = Array, ?string $domain = NULL, ?string $locale = NULL)
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)
Just navigate to:只需导航到:
vendor/symfony/translation-contracts/TranslatorInteface.php
供应商/symfony/translation-contracts/TranslatorInterface.php
and delete all the string
keywords from the trans()
function并从
trans()
function 中删除所有string
关键字
--EDIT-- - 编辑 -
If you don't want to edit vendor files, you can use this: Open your composer.json file, and add this in "require"
如果您不想编辑供应商文件,可以使用:打开您的 composer.json 文件,并将其添加到
"require"
中
"symfony/translation": "4.3.8",
“symfony/翻译”:“4.3.8”,
Then open your terminal and type this:然后打开你的终端并输入:
composer update
作曲家更新
It is not a bug.这不是一个错误。
The latest version of symfony packages requires PHP version to be at-least 7.2.5最新版本的 symfony 软件包要求 PHP 版本至少为 7.2.5
Change the PHP version to 7.2.5 or greater and it should work.将 PHP 版本更改为 7.2.5 或更高版本,它应该可以工作。
On my server following were configurations:在我的服务器上,以下是配置:
PHP 7.2 Laravel Framework 6.*
Solution: Added "symfony/translation": "4.3.8" in composer.json as follows解决方案:在composer.json中添加“symfony/translation”:“4.3.8”如下
"require": {
...
"symfony/translation": "4.3.8",
}
and then接着
composer update
Updating my PHP version to 7.3 works for me.将我的 PHP 版本更新到 7.3 对我有用。
"symfony/translation": "4.3.8" in composer.json, Its helped me.!!Thanks a lot. “symfony/translation”:composer.json 中的“4.3.8”,它帮助了我。!!非常感谢。
I found simple solution to this problem after roaming google so long.在漫游谷歌这么久之后,我找到了解决这个问题的简单方法。 If it could help someone.
如果它可以帮助某人。 Upgrading your PHP Version to 7.2 or more
将您的 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
Following these steps should help you getting rid of this issue遵循这些步骤应该可以帮助您摆脱这个问题
Update your PHP version.更新您的 PHP 版本。 This often comes as a result of running
composer update
with a different version of PHP.这通常是由于使用不同版本的 PHP 运行
composer update
导致的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.