热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

未捕获的反射异常:类日志不存在Laravel5.2。-UncaughtReflectionException:ClasslogdoesnotexistLaravel5.2

Iamcurrentlytryingtocloneanexistingprojectofminefromgithub.AftercloneIruncomposeri

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:

我看到有人提到:

  • Removing spaces within the .env file.
  • 删除.env文件中的空格。
  • Removing the vendor directory & re-installing
  • 删除供应商目录并重新安装
  • Removing certain packages required in composer.json
  • 删除复合.json中需要的某些包

I have:

我有:

  • Replaced my .env with the example.env to avoid any custom config errors.
  • 用这个例子代替我的。env。env以避免任何自定义配置错误。
  • I have removed & re-cloned the repo.
  • 我已经删除并重新克隆了repo。
  • I have used the default composer.json shipped with Laravel to see if that makes a difference.
  • 我使用了默认的编写器。Laravel附带了json,看看这是否会有所不同。

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.

如有任何帮助,我们将不胜感激。提前谢谢。

14 个解决方案

#1


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!

我希望这能帮助某人!

#2


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,也许我们应该请求这个特性

#3


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。

#4


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

#5


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=“具有某些空格的值”

#6


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:

解决方案,如何发现问题:

  • make a backup copy of config folder. try to delete one config at a
  • 制作配置文件夹的备份。尝试删除一个配置
  • time and try to run composer/artisan command that failed. When you
  • 时间和尝试运行composer/artisan命令失败。当你
  • find file that failed - search for a row that can possibly fail.
  • 查找失败的文件——搜索可能失败的行。
  • Reason why it is failed is: You use class constant that is not loaded
  • 失败的原因是:您使用了未加载的类常量
  • yet. You use class/function that is not loaded yet. etc
  • 然而。您使用尚未加载的类/函数。等

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

#7


1  

In my case, the missing of PDO extension was the problem. After installing it, the problem was fixed.

在我的例子中,缺少PDO扩展是问题所在。安装后,问题得到了解决。

#8


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:

在多次试图解决包括:

  1. rewriting, removing .env for potential parse issues
  2. 重写,删除.env以解决潜在的解析问题
  3. php7.1 and the mcrypt / mbstring issues
  4. php7.1和mcrypt / mbstring问题。
  5. installing composer suggested packages
  6. 作曲家建议安装包
  7. updating homestead.rb
  8. 更新homestead.rb
  9. PATH related issues
  10. 路径相关问题

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)
  • 1.0.1(默认)

and laravel/homestead-7:

和laravel / homestead-7:

  • 0.2.1
  • 0.2.1

#9


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'

#10


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非常好的解释了错误。

#11


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文件。我纠正了这个错误,错误就消失了。

#12


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",
    ],
]
];

#13


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 ...

谢谢……

#14


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命令……祝你好运。


推荐阅读
  • 篇首语:本文由编程笔记#小编为大家整理,主要介绍了未找到类'MaddHatterLaravelFullcalendarServiceProvider'相关的知识,希望对你 ... [详细]
  • php composer 安装,phpstudy  composer 使用安装
    本人是windows系统phpstudy是最新2018版本以安装laravel框架为例子一如图一,点击phpComposer出现系统指令框,根据指令框路 ... [详细]
  • 支持composer的php,composer配置
    本文目录一览:1、PHP与composer结合-使用命名空间实现文件自动加载 ... [详细]
  • Composer是PHP的一个依赖管理工具。它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们。下载Composer的可执行文件局部安装要真正获取Composer ... [详细]
  • phpcomposer 那个中文镜像是不是凉了 ... [详细]
  • syncd是一款开源的代码部署工具,它具有简单、高效、易用等特点,可以提高团队的工作效率. ... [详细]
  • 拖拽验证:简单、便捷、安全
    最近看到一些拖拽验证码的帖子,本着好奇和研究学习的态度简单实现了第一版的拖拽验证项目地址:github.comRLOFLSdrag-captcha示例逻辑:apiphpDragge ... [详细]
  • windows下composer命令无效的解决办法
    开发工具|composerwindows,composer开发工具-composer下面由composer教学栏目给大家介绍windows下composer安装不了或compose ... [详细]
  • Harbor安装快速简单安装(易用)
    在网上下载docker-compose工具。[rootdocker01~]#wgethttps:github.comdockercomposereleasestag1.24.0- ... [详细]
  • 七、使用Angular命令行界面的渐进式网络应用正如我们在第3章中提到的理解A ... [详细]
  • CentOS 6.5安装VMware Tools及共享文件夹显示问题解决方法
    本文介绍了在CentOS 6.5上安装VMware Tools及解决共享文件夹显示问题的方法。包括清空CD/DVD使用的ISO镜像文件、创建挂载目录、改变光驱设备的读写权限等步骤。最后给出了拷贝解压VMware Tools的操作。 ... [详细]
  • 本文讨论了在openwrt-17.01版本中,mt7628设备上初始化启动时eth0的mac地址总是随机生成的问题。每次随机生成的eth0的mac地址都会写到/sys/class/net/eth0/address目录下,而openwrt-17.01原版的SDK会根据随机生成的eth0的mac地址再生成eth0.1、eth0.2等,生成后的mac地址会保存在/etc/config/network下。 ... [详细]
  • 本文介绍了前端人员必须知道的三个问题,即前端都做哪些事、前端都需要哪些技术,以及前端的发展阶段。初级阶段包括HTML、CSS、JavaScript和jQuery的基础知识。进阶阶段涵盖了面向对象编程、响应式设计、Ajax、HTML5等新兴技术。高级阶段包括架构基础、模块化开发、预编译和前沿规范等内容。此外,还介绍了一些后端服务,如Node.js。 ... [详细]
  • 本文详细介绍了git常用命令及其操作方法,包括查看、添加、提交、删除、找回等操作,以及如何重置修改文件、抛弃工作区修改、将工作文件提交到本地暂存区、从版本库中删除文件等。同时还介绍了如何从暂存区恢复到工作文件、恢复最近一次提交过的状态,以及如何合并多个操作等。 ... [详细]
  • php怎么做rpc通信(RPC通信)
    导读:很多朋友问到关于php怎么做rpc通信的相关问题,本文编程笔记就来为大家做个详细解答,供大家参考,希望对大家有所帮助!一起来看看吧!本文目录一览: ... [详细]
author-avatar
2012开始飞翔
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有