我正在尝试实施社交名媛,但遇到与身份验证器类有关的错误。我的应用找不到。

这是我控制器中的代码

<?php namespace App;

use Illuminate\Contracts\Auth\Authenticator;
use App\Repositories\UserRepository as UserRepository;
use Laravel\Socialite\Contracts\Factory as Socialite;

class AuthenticateUser {

    private $users;
    private $socialite;
    private $auth;
        public function __construct(UserRepository $users, Socialite $socialite, Authenticator $auth)
    {
        $this->users = $users;
        $this->socialite = $socialite;
        $this->auth = $auth;
    }
    public function execute($hasCode)
    {
        if ( ! $hasCode ) return $this->getAuthorisationFirst();

        $user = $this->socialite->drivers('google')->user();

        dd($user);
    }

private function getAuthorisationFirst()
{
    return $this->socialite->driver('google')->redirect();
}

}


我收到的错误是

Container.php第833行中的ReflectionException:类Illuminate \ Contracts \ Auth \ Authenticator不存在

最佳答案

似乎在laravel 5中,身份验证器现在称为Guard


身份验证器已重命名为Guard。在AuthenticateUser.php文件中,重命名“使用Illuminate \ Contracts \ Auth \ Authenticator;”。 '使用Illuminate \ Contracts \ Auth \ Guard;'并且不要忘记也在构造函数中也进行更改” –

关于php - Laravel 5身份验证器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28435151/

10-08 22:02