Uncaught ReflectionException: Class log does not exist Laravel 5.2

前端 未结 25 1828
长情又很酷
长情又很酷 2020-11-27 17:15

I am currently trying to clone an existing project of mine from github. After clone I run composer install during the process I receive the following error:

相关标签:
25条回答
  • 2020-11-27 17:17

    Run php artisan config:cache solved it for me.

    Or if you are on shared hosting without access to the Terminal/CMD, add this to your Routs.php file:

    Route::get('/config-cache', function() {
        Artisan::call('config:cache');
        return '<h1>Config cache cleared successfully</h1>';
    });
    

    Then go to yourdomain.com/config-cache to run this script.

    0 讨论(0)
  • 2020-11-27 17:17

    As previous answers has outlined we had an issue with one of our configuration files in laravel. We used the global $app variable which were no longer possible in laravel 5.2+.

    The way we found this was to check which file failed to load in the loadConfigurationFiles method in src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php.

    0 讨论(0)
  • 2020-11-27 17:19

    I had some negative value like

    BUSINESS_RECONCILIATION_DAYS=-8
    

    I needed to wrap

    BUSINESS_RECONCILIATION_DAYS="-8"
    
    0 讨论(0)
  • 2020-11-27 17:20

    Solved this issue after removing space in the .env file (view .env in sublime because vi editor doesn't show space at end of the .env file.) and run below commands.

    Commands:

    php artisan config:clear
    php artisan cache:clear
    composer dump-autoload
    php artisan clear-compiled
    
    0 讨论(0)
  • 2020-11-27 17:21

    Remove file bootstrap/cache/config.php . This file may not be displayed on windows, if so, use double commander for example. Definitelly will work!

    EDIT:

    It may be caused by caching .env file, if it's your case, try to remove bootstrap/cache/config.php

    0 讨论(0)
  • 2020-11-27 17:22

    Okay, after many hours of digging, the solution for my problem has been found. The reason why I say my problem is because the Exception is very mis-leading.

    Uncaught ReflectionException: Class log does not exist

    This exception simply means Laravel tried to log an error but couldn't instantiate Laravel's Log class. This is not due to the Log class going walk-abouts or hiding. This is because Laravel is still going through its boot process & has yet to load the Log class.

    So, this exception is thrown because an error occurred during the boot cycle of Laravel - when this error occurred it tried to throw an exception - but it can't throw an exception because the Log class is yet the be loaded. Hence the reason we get a ReflectionException

    This has occurred in all versions of Laravel the only reason we have seen the exception thrown in laravel 5.1 <= is because previously Laravel silently discarded the problem & carried on through its boot process - basically, your app would still break however you would not receive the Log class exception.

    In my particular case I didn't have the php-mysql extension installed causing Laravel to break during its boot process.

    Ultimately, it is incredibly difficult to debug what you may have done wrong due to the error been very mis-leading.

    I hope this helps someone!

    EDIT: On how to debug this error and find out WHICH missing extension/component is actually causing the problem take a look at @Ben Johnson's answer.

    0 讨论(0)
提交回复
热议问题