Mar*_*sen 7 php laravel composer-php
我正在更新到Laravel 5.4,并在尝试显示登录屏幕时收到以下错误消息。
我收到以下错误消息:
找不到特征'Illuminate \ Foundation \ Auth \ AuthenticatesAndRegistersUsers'
这是AuthController类:
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Where to redirect users after logout.
*
* @var string
*/
protected $redirectAfterLogout = '/login';
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => ['getLogout']]);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
Run Code Online (Sandbox Code Playgroud)
Jac*_*lla 20
如果您使用的是 Laravel 7+,则需要首先laravel/ui通过运行以下命令来安装该软件包(因为它包含 auth 后端代码):
$composer require laravel/ui
Run Code Online (Sandbox Code Playgroud)
进而
$composer require laravel/ui
Run Code Online (Sandbox Code Playgroud)
小智 6
对于laravel 5.4,我们在此特征上有一些更改。现在我们有两个不同的特征:
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
Run Code Online (Sandbox Code Playgroud)
如果您安装了一个新的5.4 laravel应用程序,您将看到现在有了LoginController和RegisterController而不是AuthController