升级到Laravel 7时出现日期错误 [英] Error with date when upgrading to Laravel 7
问题描述
我已成功将Laravel实例升级到版本7.到目前为止,除以下错误外,一切似乎还不错.
I have successfully upgraded my Laravel instance to version 7. So far everything seems fine apart from the following error.
传递给Carbon \ CarbonInterval :: setLocalTranslator()的参数1必须 实现接口Symfony \ Component \ Translation \ TranslatorInterface, 给定的Carbon \ Translator实例,在 /var/www/laravel/vendor/nesbot/carbon/src/Carbon/Traits/Difference.php
Argument 1 passed to Carbon\CarbonInterval::setLocalTranslator() must implement interface Symfony\Component\Translation\TranslatorInterface, instance of Carbon\Translator given, called in /var/www/laravel/vendor/nesbot/carbon/src/Carbon/Traits/Difference.php
我已经遵循了升级文档,并在我的模型中添加了以下内容(但仍然存在相同的问题).
I have followed the upgrade documentation and have added the following to my models (but still having the same problem).
protected function serializeDate(DateTimeInterface $date)
{
return $date->format('Y-m-d H:i:s');
}
推荐答案
找到了它……迁移似乎并不顺利.
Found it... The migration is not going well it seems.
SO修改composer.json以迁移到laravel 7和symfony 5. 然后删除供应商文件夹并重新安装所有内容
SO modify the composer.json to migrate to laravel 7 and symfony 5. Then remove vendor folder and reinstall everything
composer clearcache
composer install
然后它又可以工作了.
这篇关于升级到Laravel 7时出现日期错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!