解决未捕获的ReflectionException:C: ... Container.php中不存在类日志:

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决未捕获的ReflectionException:C: ... Container.php中不存在类日志:相关的知识,希望对你有一定的参考价值。

我遇到了class log does not exist意外的反射异常错误。我目前正在使用Laravel 5.2。在命名空间中使用log添加到我的控制器中并没有解决这个问题。

Fatal error: Uncaught ReflectionException: Class log does not exist in C:xampphtdocslaravelvendorlaravelframeworksrcIlluminateContainerContainer.php:741 

Stack trace:

#0 C:xampphtdocslaravelvendorlaravelframeworksrcIlluminateContainerContainer.php(741): ReflectionClass->__construct('log')
#1 C:xampphtdocslaravelvendorlaravelframeworksrcIlluminateContainerContainer.php(631): IlluminateContainerContainer->build('log', Array) 
#2 C:xampphtdocslaravelvendorlaravelframeworksrcIlluminateFoundationApplication.php(674): IlluminateContainerContainer->make('log', Array) 
#3 C:xampphtdocslaravelvendorlaravelframeworksrcIlluminateContainerContainer.php(842): IlluminateFoundationApplication->make('log') 
#4 C:xampphtdocslaravelvendorlaravelframeworksrcIlluminateContainerContainer.php(805): IlluminateContainerContainer->resolveClass(Object(ReflectionParameter)) 
#5 C:xampphtdocslaravelvendorlaravelframeworksrcIlluminateContainerContainer.php(775): IlluminateConta in C:xampphtdocslaravelvendorlaravelframeworksrcIlluminateContainerContainer.php on line 741

Controller.php这样

  <?php

namespace AppHttpControllers;

use Log;
use IlluminateFoundationBusDispatchesJobs;
use IlluminateRoutingController as BaseController;
use IlluminateFoundationValidationValidatesRequests;
use IlluminateFoundationAuthAccessAuthorizesRequests;
use IlluminateFoundationAuthAccessAuthorizesResources;
use IlluminateDatabaseEloquentModelNotFoundException;

 class Controller extends BaseController
{
    use AuthorizesRequests,AuthorizesResources, DispatchesJobs, ValidatesRequests;
}

routes.php文件

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
Route::get('/', function () {
    return view('welcome');
});
答案

按照此处的建议检查.env或配置文件中的空格

https://laracasts.com/discuss/channels/general-discussion/class-log-does-not-exist?page=2

用双引号括起来(如果有的话)

以上是关于解决未捕获的ReflectionException:C: ... Container.php中不存在类日志:的主要内容,如果未能解决你的问题,请参考以下文章

致命错误:未捕获的 ReflectionException:类配置不存在

Laravel 错误:未捕获的 ReflectionException:类 App\Http\Kernel 不存在

未捕获的 ReflectionException:特使部署中不存在类哈希

Laravel 错误未捕获的异常 'ReflectionException' 并带有消息'Class App\Http\Kernel 不存在'

未捕获的 ReflectionException:类日志不存在 Laravel 5.2

在 vendor\laravel\framework\src\Illuminate\Container\Container.php 中未捕获的异常 'ReflectionException' 和消息