Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReflectionException in Container.php line 741: Class view does not exist

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:

    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?

like image 702
MikeAguilera210 Avatar asked Jan 08 '16 00:01

MikeAguilera210


3 Answers

Make sure that you have Illuminate\View\ViewServiceProvider listed in the list of providers in your config/app.php file.

Apparently there is no view service in the container and this is the provided that sets it up.

like image 52
jedrzej.kurylo Avatar answered Nov 16 '22 11:11

jedrzej.kurylo


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.

Voila. You're welcome, Future Me.

like image 33
Jordan Lapp Avatar answered Nov 16 '22 10:11

Jordan Lapp


For my future reference:

This can happen for a few reasons. Most common,

  • bootstrap/cache is not writable.
  • Missing config/view.php or this file has a syntax error.
  • Try with composer dumpautoload -o
  • On config/app.php, ViewServiceProvider and View alias must NOT be commented out.

In artisan, you may not see the exact error. If so, go to the error line, and dump the stacktrace. In this case, the file will be , Illuminate/Container/Container.php, line 741 (or the line shown on your screen. Dump the original exception with dd($e), and see where the error started from.

like image 1
shanecp Avatar answered Nov 16 '22 10:11

shanecp