简体   繁体   English

Symfony\Component\Debug\Exception\FatalErrorException laravel 错误

[英]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

or (if php version is not recommended on the server)或者(如果服务器不推荐php版本)

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.

相关问题 如何在 PHP (Laravel) 中调试“Symfony\\Component\\Debug\\Exception\\FatalErrorException”错误? - How to debug "Symfony\Component\Debug\Exception\FatalErrorException" errors in PHP (Laravel)? 在 Laravel 项目中找不到 Symfony\\Component\\Debug\\Exception\\FatalErrorException Trait - Symfony\Component\Debug\Exception\FatalErrorException Trait not found in Laravel project 找不到类“角色” [Symfony \\ Component \\ Debug \\ Exception \\ FatalErrorException] - Class 'Role" not found [Symfony\Component\Debug\Exception\FatalErrorException] FatalErrorException:错误:未找到类'Symfony \\ Component \\ Form \\ Exception \\ FormException' - FatalErrorException: Error: Class 'Symfony\Component\Form\Exception\FormException' not found Symfony \\\\ Component \\\\ Debug \\\\ Exception \\\\ FatalErrorException“,” message“:”找不到类'Authy_Api' - Symfony\\Component\\Debug\\Exception\\FatalErrorException“,”message“:”Class 'Authy_Api' not found Symfony \\ Component \\ Debug \\ Exception \\ FatalErrorException调用未定义的方法Illuminate \\ Database \\ MySqlConnection :: setReconnector() - Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to undefined method Illuminate\Database\MySqlConnection::setReconnector() 在 Laravel 上找不到类 - Symfony \\ Component \\ Debug \\ Exception \\ FatalThrowableError (E_ERROR) - Class not found on Laravel - Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Laravel 5.6 Symfony \\ Component \\ Debug \\ Exception \\ FatalThrowableError (E_ERROR) Class '\\App\\Utilisateurs' 未找到 - Laravel 5.6 Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class '\App\Utilisateurs' not found Laravel Tinker错误:Symfony \\ Component \\ Debug \\ Exception \\ FatalThrowableError:调用未定义的方法Psy \\ Configuration :: getLoop() - Laravel Tinker Error: Symfony\Component\Debug\Exception\FatalThrowableError : Call to undefined method Psy\Configuration::getLoop() Laravel 4错误Symfony \\组件\\ HttpKernel \\异常\\ NotFoundHttpException - Laravel 4 Error Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM