laravel 找不到类“Illuminate\Foundation\Auth\User”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41202936/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:56:37  来源:igfitidea点击:

Class 'Illuminate\Foundation\Auth\User' not found

phplaravellaravel-5

提问by code511788465541441

I did something and now when I try to log on using the standard Laravel Auth implimentation I get the following error

我做了一些事情,现在当我尝试使用标准 Laravel Auth 实现登录时,出现以下错误

FatalErrorException in User.php line 9: Class 'Illuminate\Foundation\Auth\User' not found

User.php 第 9 行中的 FatalErrorException:找不到类 'Illuminate\Foundation\Auth\User'

editUser.php does not exist in /vendor/laravel/framework/src/Illuminate/Foundation/Authand composer updatedid not fix it

编辑user.php的不存在/vendor/laravel/framework/src/Illuminate/Foundation/Auth,并composer update没有解决问题

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

enter image description here

在此处输入图片说明

回答by Alexey Mezenin

Check if /vendor/laravel/framework/src/Illuminate/Foundation/Auth/User.phpfile exists. If it's not, run this command:

检查/vendor/laravel/framework/src/Illuminate/Foundation/Auth/User.php文件是否存在。如果不是,请运行以下命令:

composer update

回答by Georges O.

After a composer update, if you still have this issue, run another command: composer dump-autoload

之后composer update,如果您仍然遇到此问题,请运行另一个命令:composer dump-autoload

This command won't download a thing. It just regenerates the list of all classes that need to be included in the project (autoload_classmap.php). Ideal for when you have a new class inside your project.

这个命令不会下载任何东西。它只是重新生成需要包含在项目中的所有类的列表 (autoload_classmap.php)。非常适合在项目中有新课程时使用。

To summary, this will update the autoloader class map and include all components available for the project.

总而言之,这将更新自动加载器类映射并包含项目可用的所有组件。

Does not forget to check if the correct library is included in your composer file :)

不要忘记检查您的作曲家文件中是否包含正确的库:)

If it's still not working, try composer update --no-scriptsThis fix many issues of libraries due to internal error during package installation. (usefull for production mode)

如果它仍然无法正常工作,请尝试composer update --no-scripts修复由于包安装过程中的内部错误而导致的许多库问题。(对生产模式有用)

回答by Nirav Prajapati

I have a same issue what I did is remove composer.lock and run composer install. It works fine for me.

我有同样的问题,我所做的是删除 composer.lock 并运行 composer install。这对我来说可以。