Laravel 5身份验证器

时间:2015-02-10 15:12:59

标签: php laravel laravel-5

我正在尝试实现社交网站,但我收到了与身份验证器类相关的错误。我的应用无法找到它。

这是我控制器中的代码

<?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不存在

1 个答案:

答案 0 :(得分:6)

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

  

Authenticator更名为Guard。在AuthenticateUser.php文件中重命名&#39;使用Illuminate \ Contracts \ Auth \ Authenticator;&#39;使用Illuminate \ Contracts \ Auth \ Guard;&#39;并且不要忘记在构造函数中也改变它&#34; -