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

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.


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.


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.