【问题标题】:ReflectionException in Container.php line 741: Class view does not existContainer.php 第 741 行中的 ReflectionException:类视图不存在
【发布时间】:2016-04-12 13:54:55
【问题描述】:

我正在使用 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

我不确定是什么坏了。我已经在 Laravel 5.1 中工作,并且 Composer 运行良好。我觉得我有两个基本选择:1)尝试恢复到以前版本的 Composer 或 2)恢复到我的项目的以前版本。但是,是否有更简单的解决方法?

【问题讨论】:

    标签: php laravel composer-php laravel-5.1 homestead


    【解决方案1】:

    确保您的 config/app.php 文件的提供程序列表中列出了 Illuminate\View\ViewServiceProvider

    显然容器中没有 view 服务,这是设置它的提供。

    【讨论】:

    • 做到了。非常感谢。
    • 当我尝试将语法从(仅一个示例)'Laravel\Socialite\SocialiteServiceProvider', 更新为 Laravel\Socialite\SocialiteServiceProvider::class, 时出现错误
    • 我确定它存在但仍然收到错误:(
    【解决方案2】:

    我现在已经两次遇到此错误消息,所以我将解决方案放在这里,以防将来我必须在谷歌上搜索它。

    有时会发生此错误,因为“/bootstrap/cache”目录不可写。因此,它无法编译视图。解决方案是对该目录进行 chmod,以便可以写入。

    瞧。不客气,未来的我。

    【讨论】:

    • 谢谢你!这次你真的救了我的培根。
    • 这对我有帮助:)
    • 谢谢,他们为什么不能直接输入一个错误来表明这一点!
    • upvote +20 - 或者在我的特定情况下,该目录已被删除并且它不会尝试创建它
    • 在这里放一个捐赠链接,你就会变得富有:)。你刚刚拯救了我的早晨!
    【解决方案3】:

    当“bootstrap”文件夹及其内容的权限不正确时,也会发生这种情况。对我来说,chmodding to writable 修复了它。

    【讨论】:

    【解决方案4】:

    就我而言,文件命名不正确。该类被声明为:

    class NoSessionAccessMiddleware {
    

    但是文件被命名为NoSessionAccess.php,我只是将文件重命名为NoSessionAccessMiddleware.php,它解决了这个问题。

    【讨论】:

      【解决方案5】:

      遇到同样的问题,我尝试了上述解决方案,但没有成功。运行 composer dump-autoload 后,我发现这是因为我忘记在我的开发服务器上安装一个包(Laravel Excel),但尚未在生产服务器上加载。

      【讨论】:

        【解决方案6】:

        更新我的项目命名空间后,我遇到了同样的问题。我不得不更新 composer.json 文件:

         "psr-4": {
                "App\\": "myforms/app/"
            } 
        

        到:

         "psr-4": {
                "App\\": "app/"
            }
        

        在服务器上,在您的源目录中,运行composer update,然后运行composer dump-autoload

        【讨论】:

          【解决方案7】:

          供我以后参考:

          这可能有几个原因。最常见,

          • bootstrap/cache 不可写。
          • 缺少config/view.php 或此文件存在语法错误。
          • 试试composer dumpautoload -o
          • config/app.phpViewServiceProviderView 上的别名不得注释掉。

          在 artisan 中,您可能看不到确切的错误。如果是这样,请转到错误行并转储堆栈跟踪。在这种情况下,文件将是,Illuminate/Container/Container.php,第 741 行(或屏幕上显示的行。将原始异常转储为 dd($e),并查看错误从哪里开始。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2017-05-07
            • 2016-05-16
            • 1970-01-01
            • 2016-12-27
            • 1970-01-01
            • 1970-01-01
            • 2016-04-30
            • 2021-03-03
            相关资源
            最近更新 更多