我遇到意外的反映异常错误class log does not exist
。我目前正在使用Laravel 5.2。在命名空间中添加使用log
到我的控制器中并没有解决这个问题。
Fatal error: Uncaught ReflectionException: Class log does not exist in C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php:741
Stack trace:
#0 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(741): ReflectionClass->__construct('log')
#1 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(631): Illuminate\Container\Container->build('log', Array)
#2 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(674): Illuminate\Container\Container->make('log', Array)
#3 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(842): Illuminate\Foundation\Application->make('log')
#4 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(805): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(775): Illuminate\Conta in C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 741
Controller.php这样
<?php
namespace App\Http\Controllers;
use Log;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesResources;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class Controller extends BaseController
{
use AuthorizesRequests,AuthorizesResources, DispatchesJobs, ValidatesRequests;
}
routes.php文件
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
Route::get('/', function () {
return view('welcome');
});
答案 0 :(得分:1)
按照此处的建议检查.env或配置文件中的空格
https://laracasts.com/discuss/channels/general-discussion/class-log-does-not-exist?page=2
如果有任何
,请用双引号括起来