Solving "Class not found" errors in Laravel 4
If you're new to Laravel 4 and Composer, you might be confused when you start getting errors like this:
PHP Fatal error: Class 'BlaClass' not found in project/vendor/laravel/framework/src/Illuminate/Bla/Bla.php on line xyz
This has to do with Composer's class autoloading, and is very easy to fix. Run composer dump-auto
, and then try re-running whatever you were trying to do before, which should now work.
Written by Benjamin Harris
Related protips
7 Responses
Whoa! Working ! cool, I'm just wondering why is this happening?
Thank you so much, I have been looking quite a while for an solution!
Would be helpful if you had some suggestions for when dump_autoload doesn't suffice.
I still get Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'View' not found
It's like if Laravel isn't loading the Views class? How to verify that ?
+1: it'd be helpful if you had some more troubleshooting tips. Autoloading is awesome, except when it doesn't work... then it's power is turned against you.
If you're in a package and it's still not working, you need to prepend your class name with a \
\View::make('index');
wow..! append with \ works for me
i don't know the reason of using '\'. can anyone explain..?
Because the '\' forces to use the namespace starting from root!