11

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?

MikeAguilera210
  • 113
  • 1
  • 1
  • 4

7 Answers7

33

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.

Jordan Lapp
  • 982
  • 9
  • 19
8

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.

jedrzej.kurylo
  • 39,591
  • 9
  • 98
  • 107
1

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.

shanecp
  • 650
  • 6
  • 15
0

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.

Haris ur Rehman
  • 2,593
  • 30
  • 41
0

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.

Dylan Glockler
  • 1,115
  • 1
  • 20
  • 40
0

I had the same problem after updating my projects namespace. I had to update the composer.json file:

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

to:

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

On the server, in your source directory, run composer update then composer dump-autoload

Jeremy
  • 3,620
  • 9
  • 43
  • 75
-5

This also can occur when the permissions on the 'bootstrap' folder and its contents are not right. For me chmodding to writable fixed it.

  • 2
    This answer duplicates what https://stackoverflow.com/a/35833239/470749 already says. – Ryan Sep 19 '18 at 03:20