laravel Container.php 第 741 行中的 ReflectionException:类视图不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34667625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ReflectionException in Container.php line 741: Class view does not exist
提问by MikeAguilera210
I'm working on a Laravel 5.1 project with Homestead. I shelled into my Vagrant machine and ran the Composer Update command in an attempt to try to update my project and now I get the following error:
我正在与 Homestead 合作开展 Laravel 5.1 项目。我进入我的 Vagrant 机器并运行 Composer Update 命令以尝试更新我的项目,现在我收到以下错误:
1. in Container.php line 741
2. at ReflectionClass->__construct('view') in Container.php line 741
3. at Container->build('view', array()) in Container.php line 631
4. at Container->make('view', array()) in Application.php line 674
5. at Application->make('Illuminate\Contracts\View\Factory') in Container.php line 842
6. at Container->resolveClass(object(ReflectionParameter)) in Container.php line 805
7. at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 776
8. at Container->build('Illuminate\View\Middleware\ShareErrorsFromSession', array()) in Container.php line 631
9. at Container->make('Illuminate\View\Middleware\ShareErrorsFromSession', array()) in /home/vagrant/Sites/laravel-basics/vendor/laravel/framework/src/Illuminate/Foundation/Application.php line 674
10. at Application->make('Illuminate\View\Middleware\ShareErrorsFromSession') in Pipeline.php line 123
11. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
12. at StartSession->handle(object(Request), object(Closure))
13. at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
14. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
15. at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
16. at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
17. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
18. at EncryptCookies->handle(object(Request), object(Closure))
19. at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
20. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
21. at CheckForMaintenanceMode->handle(object(Request), object(Closure))
22. at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
23. at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
24. at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
25. at Pipeline->then(object(Closure)) in Kernel.php line 122
26. at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
27. at Kernel->handle(object(Request)) in index.php line 54
I'm not sure what broke. I had already been working in Laravel 5.1 and Composer was running just fine. I feel that I have two basic options: 1) try to revert back tot he previous version of Composer or 2) revert to a previous version of my project. However, is there a simpler fix for this?
我不确定是什么坏了。我已经在 Laravel 5.1 中工作了,而且 Composer 运行得很好。我觉得我有两个基本选择:1) 尝试恢复到以前版本的 Composer 或 2) 恢复到我项目的以前版本。但是,有没有更简单的解决方法?
采纳答案by jedrzej.kurylo
Make sure that you have Illuminate\View\ViewServiceProviderlisted in the list of providers in your config/app.phpfile.
确保在config/app.php文件的提供程序列表中列出了Illuminate\View\ViewServiceProvider。
Apparently there is no viewservice in the container and this is the provided that sets it up.
显然容器中没有视图服务,这是设置它的条件。
回答by Jordan Lapp
I've encountered this error message twice now, so I'm putting the solution here in case I have to google it some time in the future.
我现在已经两次遇到此错误消息,所以我将解决方案放在这里,以防将来我必须在谷歌上搜索它。
This error sometimes occurs because the "/bootstrap/cache" directory isn't writable. Hence, it can't compile a view. The solution is to chmod that directory so that it can be written to.
有时会发生此错误,因为“/bootstrap/cache”目录不可写。因此,它无法编译视图。解决方案是 chmod 那个目录,以便它可以被写入。
Voila. You're welcome, Future Me.
瞧。不客气,未来的我。
回答by Haris ur Rehman
In my case, the file was not named correctly. The class was declared as :
就我而言,该文件未正确命名。该类被声明为:
class NoSessionAccessMiddleware {
but the file was named as NoSessionAccess.php
, I just renamed the file to NoSessionAccessMiddleware.php
and it fixed the issue.
但是该文件被命名为NoSessionAccess.php
,我只是将文件重命名为NoSessionAccessMiddleware.php
并解决了该问题。
回答by Dylan Glockler
Had the same issue, I tried the above solutions with no luck. After running composer dump-autoload, I discovered it was because I had forgotten to install a package (Laravel Excel) I had setup on my dev server that wasn't yet loaded on the production server.
遇到了同样的问题,我尝试了上述解决方案但没有成功。运行 composer dump-autoload 后,我发现这是因为我忘记安装一个包(Laravel Excel),我在我的开发服务器上设置了尚未加载到生产服务器上的包。
回答by Jeremy Quick
I had the same problem after updating my projects namespace. I had to update the composer.json file:
更新我的项目命名空间后,我遇到了同样的问题。我不得不更新 composer.json 文件:
"psr-4": {
"App\": "myforms/app/"
}
to:
到:
"psr-4": {
"App\": "app/"
}
On the server, in your source directory, run composer update
then composer dump-autoload
在服务器上的源目录中,composer update
然后运行composer dump-autoload
回答by Jonathan Vasquez
This also can occur when the permissions on the 'bootstrap' folder and its contents are not right. For me chmodding to writable fixed it.
当“bootstrap”文件夹及其内容的权限不正确时,也会发生这种情况。对我来说,chmodding to writable 修复了它。