Laravel无法声明类Symfony \ Component \ HttpFoundation \ AcceptHeader,因为该名称已在使用中

时间:2019-01-26 23:21:51

标签: php laravel symfony-components

我刚刚接受了几个月前在Laravel制作的一个项目。该项目还利用了Laravel Voyager-管理面板程序包。

浏览到http://example.com/admin之后,我得到了这个奇怪的错误,它从无处发生,而且我也不确定如何调试它。看起来像这样:

Fatal error: Cannot declare class Symfony\Component\HttpFoundation\AcceptHeader, because the name is already in use in /c/Users/User/Code/example-website/vendor/symfony/http-foundation/AcceptHeader.php on line 22

Fatal error: Uncaught Error: Class 'Symfony\Component\HttpFoundation\AcceptHeaderItem' not found in /c/Users/User/Code/example-website/vendor/symfony/http-foundation/AcceptHeader.php:61 Stack trace: #0 [internal function]: Symfony\Component\HttpFoundation\AcceptHeader::Symfony\Component\HttpFoundation\{closure}(Array) #1 /c/Users/User/Code/example-website/vendor/symfony/http-foundation/AcceptHeader.php(57): array_map(Object(Closure), Array) #2 /c/Users/User/Code/example-website/vendor/symfony/http-foundation/Request.php(1664): Symfony\Component\HttpFoundation\AcceptHeader::fromString('text/html,appli...') #3 /c/Users/User/Code/example-website/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php(54): Symfony\Component\HttpFoundation\Request->getAcceptableContentTypes() #4 /c/Users/User/Code/example-website/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php(44): Illuminate\Http\Request->wantsJson() #5 /c/Users/User/Code/example-website/vendor/laravel/framework/src/Illumina in /c/Users/User/Code/example-website/vendor/symfony/http-foundation/AcceptHeader.php on line 61

这个错误是非常可预期的,我从未在我的项目中(或与此相关的其他任何地方)见过。

如何调试此问题?

1 个答案:

答案 0 :(得分:0)

作为健全性检查,删除vendor目录,然后运行composer install以重新获取依赖项,并查看错误是否已解决。如果没有,请尝试composer update来获取依赖关系的最新版本,其中可能已解决了该问题。