Laravel 5.1 Class '\App\User' 未找到,EloquentUserProvider.php 第 126 行中的 FatalErrorException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36442929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5.1 Class '\App\User' not found, FatalErrorException in EloquentUserProvider.php line 126
提问by Qazi
I moved my User
Model from App\User
to App\Models\Users
, I followed the proper instruction, the same thing working properly on Windows OS, while facing error on Ubuntu 14.04
我将我的User
模型从移动App\User
到App\Models\Users
,我遵循了正确的说明,同样的事情在 Windows 操作系统上正常工作,同时在Ubuntu 14.04
Whenever I try to Login(When submit information)
it gives me error
每当我尝试Login(When submit information)
它时都会给我错误
FatalErrorException in /var/www/html/sms/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
line 126: Class '\App\User' not found
/var/www/html/sms/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php 中的 FatalErrorException
第 126 行:找不到“\App\User”类
I also run composer dump-autoload
command, but no luck.
Also tried this
我也运行composer dump-autoload
命令,但没有运气。也试过这个
https://stackoverflow.com/a/28516582/1216451
https://stackoverflow.com/a/28516582/1216451
Here is my settings for Models
directory
这是我的Models
目录设置
composer.json
作曲家.json
"autoload": {
"classmap": [
"database",
"app/Models"
],
"psr-4": {
"App\": "app/"
}
},
Model Directory StructureApp/Models/
模型目录结构App/Models/
ModelUser.php
模型User.php
namespace App\Models;
Auth.phptried both lines, given below.
Auth.php尝试了两行,如下所示。
'model' => App\Models\User::class,
'model' => App\Models\User,
AuthController.php
验证控制器.php
use App\Models\User;
EloquentUserProvider.phppath is sms/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php line 126
EloquentUserProvider.php路径是sms/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php line 126
public function createModel()
{
$class = '\'.ltrim($this->model, '\');
return new $class; //line# 126
}
回答by N.J
Your configurations seems accurate, just reset them by using php artisan config:clear
您的配置似乎准确,只需使用php artisan config:clear