dtdvbf37193
2019-01-26 23:21
浏览 225
已采纳

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

I just took a project from a couple of months ago which was made in Laravel. This project also utilizes Laravel Voyager - the admin panel package.

After browsing to http://example.com/admin, I got this weird error which came out of nowhere and I'm also unsure how to debug it. It looks like this:

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

This error is very expected and I've never seen it before in my project (or anywhere else for that matter).

How can I debug this issue?

图片转代码服务由CSDN问答提供 功能建议

我刚刚参加了几个月前在Laravel制作的项目。 该项目还使用了Laravel Voyager - 管理面板包。

浏览 http: //example.com/admin ,我得到了这个奇怪的错误,这个错误来自哪儿,我也不确定如何调试它。 它看起来像这样:

 致命错误:无法声明类Symfony \ Component \ HttpFoundation \ AcceptHeader,因为该名称已在/ c / Users / User / Code /中使用 第22行的example-website / vendor / symfony / http-foundation / AcceptHeader.php 
 
发生错误:未捕获错误:在/ c / Users / User / Code / example中找不到类'Symfony \ Component \ HttpFoundation \ AcceptHeaderItem'  -website / vendor / symfony / http-foundation / AcceptHeader.php:61堆栈跟踪:#0 [内部函数]:Symfony \ Component \ HttpFoundation \ AcceptHeader :: Symfony \ Component \ HttpFoundation \ {closure}(数组)#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):Symfon  y \ Component \ HttpFoundation \ Request-> getAcceptableContentTypes()#4 /c/Users/User/Code/example-website/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php(44):照亮 \ Http \ Request-> wantsJson()#5 / c / Users / User / Code / example-website / vendor / laravel / framework / src / Illumina in / c / Users / User / Code / example-website / vendor / 第61行的symfony / http-foundation / AcceptHeader.php 
   
 
 

这个错误是非常期待的,我以前从未在我的项目中看到它(或其他任何地方 那件事。)

如何调试此问题?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dqw7121 2019-01-27 05:11
    已采纳

    As a sanity check, delete the vendor directory and then run composer install to re-fetch your dependencies and see if the error is resolved. If not, then attempt composer update to fetch the latest versions of your dependencies in which this issue may have been resolved.

    打赏 评论

相关推荐 更多相似问题