更改名称空间时在Laravel中找不到类'\ App \ User'

问题描述:

User.php移至Models/User.php

local.ERROR:Symfony \ Component \ Debug \ Exception \ FatalThrowableError:致命错误: 找不到类'\ App \ User'

local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class '\App\User' not found

vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php:126

vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php:126

转到config/auth.php,将App \ User:class更改为App \ Models \ User :: class.

Go to config/auth.php and change App\User:class to App\Models\User::class.

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],

还更改User.php模型的命名空间

Also change the namespace of User.php model

namespace App\Models;