繁体   English   中英

Spark Laravel 5.4中未定义的类社交名称

[英]Undefined class Socialite in Spark Laravel 5.4

我是Laravel和Spark的新手,试图弄清楚我应该如何/在哪里添加我的新控制器并添加Socialite。

在我的提供者中我添加了

Laravel\Socialite\SocialiteServiceProvider::class,

在我的别名中,我补充道

'Socialite' => Laravel\Socialite\Facades\Socialite::class,

这是我的app / HTTP / Controllers / Auth / LoginController类的样子

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Socialite;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    /**
     * Redirect the user to the GitHub authentication page.
     *
     * @return Response
     */
    public function redirectToProvider()
    {
        return Socialite::with('github')->redirect();
    }

    /**
     * Obtain the user information from GitHub.
     *
     * @return Response
     */
    public function handleProviderCallback()
    {
        $user = Socialite::driver('github')->user();

        // $user->token;
    }
}

当我添加use Socialite;时,我得到未定义的类use Socialite;

我尝试过composer dump-autoloadphp artisan config:clear但没有任何工作。 难道我做错了什么?

我正在使用Laravel 5.4和Socialite 3.0

谢谢!

php artisan clear-compiled 
composer dump-autoload
php artisan optimize

这将清除当前编译的文件,更新它所需的类,然后将它们写回,这样您就不必再这样做了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM