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:
我目前正在尝试从github克隆一个现有的项目。在克隆之后,我运行了编写器安装过程中,我收到以下错误:
Uncaught ReflectionException: Class log does not exist
未捕获的反射异常:类日志不存在。
I am running Laravel 5.2 on Centos 7.
我在Centos 7上运行Laravel 5.2。
I have seen references to:
我看到有人提到:
.env
file. I have:
我有:
.env
with the example.env
to avoid any custom config errors. composer.json
shipped with Laravel to see if that makes a difference. None of the above have brought me any joy. I also have the same environment set up on another machine with the application working fine. The only difference here is the machine (working) wasn't cloned from git - it was the initial build environment.
以上这些都没有给我带来任何快乐。我在另一台机器上设置了相同的环境,应用程序运行良好。这里唯一的区别是机器(工作)不是从git克隆出来的——它是初始的构建环境。
The stack trace I am receiving:
我正在接收的堆栈跟踪:
PHP Fatal error: Uncaught ReflectionException: Class log does not exist in /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php:736
Stack trace:
#0 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(736): ReflectionClass->__construct('log')
#1 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('log', Array)
#2 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('log', Array)
#3 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(845): Illuminate\Foundation\Application->make('log')
#4 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(800): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php(769): Illuminate\Container\Container->getDependenc in /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 736
Any help would be much appreciated. Thanks in advance.
如有任何帮助,我们将不胜感激。提前谢谢。
40
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.
这个异常仅仅意味着Laravel试图记录一个错误,但是无法实例化Laravel的日志类。这并不是由于日志类的走向或隐藏。这是因为Laravel仍在进行引导过程&还没有加载Log类。
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
因此,这个异常被抛出,因为在Laravel的启动周期中发生了一个错误——当这个错误发生时,它试图抛出一个异常——但是它不能抛出异常,因为日志类仍然是被加载的。因此我们得到了一个反射异常
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
.
这发生在所有版本的Laravel唯一原因我们看到异常抛出Laravel 5.1 <=是因为以前Laravel默默地丢弃的问题&继续通过其引导过程——基本上,应用程序仍然会休息但是你不会收到日志类例外。
In my particular case I didn't have the php-mysql
extension installed causing Laravel to break during its boot process.
在我的例子中,我没有安装php-mysql扩展,导致Laravel在引导过程中崩溃。
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!
我希望这能帮助某人!
21
In your .env file make sure you have no spaces for values
在.env文件中,确保没有值的空格
for example this is allowed
例如,这是允许的
DB_USERNAME=homestead
this is not not allowed
这是不允许的
DB_USERNAME=home stead
you can wrap the value in quotes if you have spaces.
如果有空格,可以用引号括起来。
DB_USERNAME="home stead"
really wish they used json for the .env file, maybe we should request that feature
真希望他们为.env文件使用json,也许我们应该请求这个特性
15
The underlying error is revealed by modifying vendor/laravel/framework/src/Illuminate/Container/Container.php
and placing the following at the top:
通过修改供应商/laravel/框架/src/ lighting /Container/Container,可以发现潜在的错误。php,并将以下放在顶部:
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.)
(这要归功于https://laracasts.com/discuss/channels/generdiscussion /class-log-does-not-exist/replies/160902)。
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 .
要添加到此消息的根源列表中,在配置文件中定义一个闭包并随后调用php artisan配置:cache将导致这个结果(至少在Laravel 5.1中)。解决方案:不要在Laravel配置文件中定义闭包,参见https://github.com/laravel/framework/issues/9625。
6
Remove file bootstrap/cache/config.php
. This file may not be displayed on windows, if so, use double commander for example. Definitelly will work!
删除缓存文件引导/ /配置。php。这个文件可能不会显示在windows上,如果是的话,可以使用double commander。Definitelly将工作!
EDIT:
编辑:
It may be caused by caching .env file, if it's your case, try to remove bootstrap/cache/config.php
它可能是由缓存.env文件引起的,如果是您的情况,请尝试删除bootstrap/cache/config.php
3
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:
在我的.env文件中添加了几行之后,我注意到了相同的行为。空格是不允许没有引号的,所以这可以是固定的:
APP_YOUR_NAME="A value with some spaces"
APP_YOUR_NAME=“具有某些空格的值”
2
I was typing a CMD in the CLI and accidentally typed it in the app config file. I had to follow this procedure in order to find the problem.
我在CLI中输入CMD,并意外地在应用程序配置文件中键入它。为了找出问题所在,我不得不遵循这个程序。
Solution, how to find problem:
解决方案,如何发现问题:
https://laracasts.com/discuss/channels/general-discussion/class-log-does-not-exist?page=2
https://laracasts.com/discuss/channels/general-discussion/class-log-does-not-exist?page=2
1
In my case, the missing of PDO extension was the problem. After installing it, the problem was fixed.
在我的例子中,缺少PDO扩展是问题所在。安装后,问题得到了解决。
1
EDIT::
编辑::
Because I wasn't satisfied with the rather clumsy debugging and reworking paths, etc to get the VM running smoothly, I reflected on the process and reinstalled the vagrant box laravel/homestead (virtualbox 1.0.1
)
因为我对笨拙的调试和重构路径等使VM顺利运行不满意,所以我反思了一下过程,重新安装了流浪箱laravel/homestead (virtualbox 1.0.1)
For me the issue potentially stemmed from a missing comma in config/app.php
. The missing comma likely halted the compilation process and spit out the Uncaught ReflectionException: Class log does not exist
error.
对我来说,这个问题可能是由于配置/app.php中缺少了一个逗号。缺失的逗号可能会停止编译过程,并吐出未捕获的反射异常:类日志不存在错误。
This is not a direct answer, but serves more as a guide post to those who venture into this abyss of silent errors
这不是一个直接的答案,但更多的是对那些冒险进入无声错误深渊的人的指导
System: macOS Sierra
系统:macOS塞拉
Vagrant: 1.9.1
(Latest Version at time of writing)
流浪汉:1.9.1(写作时最新版本)
VM: laravel/homestead (virtualbox 0.4.0
)
虚拟机:laravel /家园(virtualbox 0.4.0)
Laravel Version: 5.1.*
Laravel版本:5.1 . *
PHP: 7.0.*
PHP:7.0 . *
After repeated attempts to resolve the issue which include:
在多次试图解决包括:
Critically, (for me) it seemed it was the virtualbox version in the initial set up:
关键的是,(对我来说)似乎是初始设置中的虚拟框版本:
vagrant box add laravel/homestead
流浪的框添加laravel /家园
Instead try supplying the version number like so:
试着提供版本号如下:
vagrant box add laravel/homestead
--box-version 0.4.0
流浪箱添加laravel/homestead——box版本0.4.0
misc:
misc:
I have attempted and failed with the following laravel/homestead
virtualbox versions:
我尝试过以下laravel/homestead virtualbox版本,但失败了:
1.0.1
(default)and laravel/homestead-7
:
和laravel / homestead-7:
0.2.1
0
This problem is usually caused by spaces between words in the .env file. Make sure if you have something like
这个问题通常是由.env文件中的字之间的空格引起的。确保你有类似的东西。
SITE_DESCRIPTION = Social Network for dogs
you replace it with
你把它换成
SITE_DESCRIPTION = 'Social Network for dogs'
0
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.
在我的例子中,我在配置文件中使用了route()方法。显然,这个方法不起作用,因为这些文件不使用说明助手,它们是简单的.php和数据。
The configuration files are read before instantiating the Log class, which causes the error that Jakehallas explains very well.
配置文件在实例化日志类之前被读取,这导致了jhallakeas非常好的解释了错误。
0
Also this is due to a syntax error in some file in the conf/ directory or .env file. In my case I got this error because I forget to put ::class
at the end of the line when adding a service provider and facade, to the array providers and alises in conf/app.php file. I corrected this and the error disappeared.
这也是由于conf/目录或.env文件中的某些文件的语法错误造成的。在我的例子中,我犯了这个错误,因为在向数组提供程序添加服务提供程序和facade时,我忘记在行尾加上::class,并在conf/app中显示。php文件。我纠正了这个错误,错误就消失了。
0
Uncaught ReflectionException: Class log does not exist
This Error Comes laravel 5.2 & > versions:
这个错误来自laravel 5.2和>版本:
My mistakes are:
我的错误是:
Tips1: when You missing (;) end of your code in config File
Tips1:当在配置文件中缺少(;)结束代码时
Other syntax Error This error comes.
其他语法错误。
My Error code:
我的错误代码:
[
'common' => [
'AuthKey1' => "17086...........9a87a1",
'AuthKey2' => "17086...........9a87a1",
'AuthKey3' => "17043...........59969531",
],
]
]
Correct code: Missing (;) End of return Array
正确的代码:失踪(,)年底返回数组
[
'common' => [
'AuthKey1' => "17086...........9a87a1",
'AuthKey2' => "17086...........9a87a1",
'AuthKey3' => "17043...........59969531",
],
]
];
0
Yes as said by @jakehallas . Its not related to what is showing in exception.
是的,@jakehallas说过。它与例外情况无关。
Actually if there is any dababase issue or other config varilables issue causes this.
实际上,如果有任何dababase问题或其他配置变量问题,就会导致这个问题。
Actually when i tried to change something in database.php i just duplicated same file as database-copy.php. I didn't execpt this causes issue.
实际上,当我尝试在数据库中改变一些东西的时候。我只是复制了与database-copy.php相同的文件。我没有预料到这个原因。
After gone through what i have done before i just removed this database-copy.php file its working fine..
在完成之前的操作之后,我刚刚删除了这个数据库拷贝。php文件运行良好。
Thanks ...
谢谢……
0
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:
这个错误可能是由一个配置文件中的错误引起的。要找到导致它的文件,请更改/vendor/laravel/framework/src/ illuminrc /Foundation/Bootstrap/LoadConfiguration中的函数loadConfigurationFiles。php:
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.
运行php artisan,最后一次加载“key”是导致错误的配置文件。纠正它,不要忘记删除var_dump命令……祝你好运。