Fix Uncaught ReflectionException: Class log does not exist …/laravel/framework/…

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
  • Digg

I again got this error which left me no clue of what happened wrong and how can I fix it.

PHP Fatal error: Uncaught ReflectionException: Class log does not exist in .../vendo/laravel/framework/src/Illuminate/Container/Container.php:741

I tried to find solution on google for a while and came to know that this don’t tell what acually went wrong. There can be different things which can be in different case. And you will find nothing other than someone will be telling that this error just mean something crashed earlier on before that interface was bound. So it tells nothing useful.

I found different reasons for this, but most commonly it was after you updated something in your system, which effected some extension of php or something else went wrong.

Here I am not going to dig deeper into why it happened because there can be lot of different reasons, I am just trying to tell a way by which I came to know the reason and fixed it. It happened to me twice in last few months and I found nothing on stackoverflow so that’s why I am writing it here.

So here are steps to find the reason and fix:

  1. Good thing about Laravel is that it checks some obvious dependencies which are required for Laravel to function properly. So go to some other directory and try installing Laravel’s same version there.  You can install it using
    composer create-project --prefer-dist laravel/laravel blog

    while in my case I was using Laravel bootstrap so I ran

    composer create-project graham-campbell/bootstrap-cms --prefer-dist -s dev
  2. It will show you missing dependencis, so you can see the dependencies and try to resolve them by installing missing extensions. In my case it was ext-mbstring  missing and in someone else’s case it was php-mysql extension missing. So install whatever extension is missing in your case.
  3. After installing extension don’t forget to restart apache:
    sudo service apache2 restart
  4. Once you have those extensions installed and your able to complete Laravel installation, go back to actual Laravel installation directory where you were actually facing above mentioned issue.
  5. Once you are there, give all permissions to `storage` and `bootstrap/cache` directories in Laravel installation by doing:
    sudo chmod 777 storage -R
    sudo chmod 777 bootstrap/cache -R
  6.  Now execute following command:
    php artisan clear-compiled
  7. If you see error like:
    PHP Fatal error: Trait 'Illuminate\Auth\Access\HandlesAuthorization' not found in ...dynamic/bootstrap/cache/compiled.php on line 737
    Script php artisan clear-compiled handling the post-install-cmd event returned with an error[RuntimeException]Error Output: PHP Fatal error: Trait 'Illuminate\Auth\Access\HandlesAuthorization' not found in /var/www/html.../bootstrap/cache/comp

    Delete the contents of the bootstrap/cache folder, then run

    php artisan app:update 

    and try running

     php artisan clear-compiled

    again.

  8. After doing so just run:
    composer dump-autoload
  9. And then go to your browser and try to reload. Most probably it should be working as this is how I had it working twice.

In case it still don’t work, then post it in comment and we can try to dig into that.

Share and Enjoy

Share your thoughts