Uncaught ReflectionException: Class log does not exist Laravel 5.2

前端 未结 25 1832
长情又很酷
长情又很酷 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:28

    In my case, I had used the route() method in a config file. Obviously, this method does not work because these files don't use the Illuminate Helper, they are simple .php with data.

    The configuration files are read before instantiating the Log class, which causes the error that Jakehallas explains very well.

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

    The underlying error is revealed by modifying vendor/laravel/framework/src/Illuminate/Container/Container.php and placing the following at the top:

    <?php
    
    namespace {
        use Monolog\Logger as Monolog;
        class log extends Illuminate\Log\Writer {
           function __construct()
           {
                $this->monolog = new Monolog("local");
           }
        }
    }
    
    //Add curly-braces around the original content, like so:
    
    namespace Illuminate\Container {
        //All original code in this file goes here.
    
        //...
    }
    

    (Credit to https://laracasts.com/discuss/channels/general-discussion/class-log-does-not-exist/replies/160902 for this idea.)

    To add to the list of root-causes for this message, defining a closure in a configuration file and calling php artisan config:cache subsequently will cause this (at least in Laravel 5.1). Solution for this manifestation: don't define closures in Laravel configuration files, per https://github.com/laravel/framework/issues/9625 .

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

    I was noticing the same behavior after adding a few lines to my .env files. Spaces are not allowed without quotes, and so this can be fixed like:

    APP_YOUR_NAME="A value with some spaces"

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

    This error may be caused by an error in one of the config files. To locate which file is causing it, change the function loadConfigurationFiles in /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php to:

    protected function loadConfigurationFiles(Application $app, RepositoryContract $repository)
    {
        foreach ($this->getConfigurationFiles($app) as $key => $path) {
            var_dump('loading key: ' . $key . ' -- path: ' . $path);
            $repository->set($key, require $path);
        }
    }
    

    Run php artisan and the last loading "key" is the config file causing the error. Correct it and don't forget to remove the your var_dump command... Good luck.

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

    This type of error when you missed any of the dependencies of your project. Runphp composer.phar update

    0 讨论(0)
  • 2020-11-27 17:32
    Uncaught ReflectionException: Class log does not exist
    

    This Error Comes laravel 5.2 & > versions:

    My mistakes are:

    Tips1: when You missing (;) end of your code in config File

    Other syntax Error This error comes.

    My Error code:

    <?php
    return [
    'data' => [
        'common' => [
            'AuthKey1' =>  "17086...........9a87a1",
            'AuthKey2' =>  "17086...........9a87a1",
            'AuthKey3'   =>  "17043...........59969531",
        ],
    ]
    ]
    

    Correct code: Missing (;) End of return Array

    <?php
    return [
    'data' => [
        'common' => [
            'AuthKey1' =>  "17086...........9a87a1",
            'AuthKey2' =>  "17086...........9a87a1",
            'AuthKey3'   =>  "17043...........59969531",
        ],
    ]
    ];
    
    0 讨论(0)
提交回复
热议问题