发布于 4年前

Laravel 报错 Symfony\Component\Debug\Exception\FatalErrorException laravel Error

新建Laravel项目时遇到如下错误:

Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)

解决方案: 找到项目

vendor/symfony/translation-contracts/LocaleAwareInteface.php

删除setLocale() 方法中的string关键字

如果在这里报错:

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)

只需要找到vendor/symfony/translation-contracts/TranslatorInteface.php,并删除 trans() 方法中的所有 string关键字

©2020 edoou.com   京ICP备16001874号-3