简体   繁体   English

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

[英]Undefined class Socialite in Spark Laravel 5.4

I'm new to Laravel and Spark trying to figure out how/where I should add my new Controllers and add Socialite. 我是Laravel和Spark的新手,试图弄清楚我应该如何/在哪里添加我的新控制器并添加Socialite。

In my providers I added 在我的提供者中我添加了

Laravel\Socialite\SocialiteServiceProvider::class,

In my aliases I added 在我的别名中,我补充道

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

Here's what my app/HTTP/Controllers/Auth/LoginController class looks like 这是我的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;
    }
}

I get undefined class Socialite when I add use Socialite; 当我添加use Socialite;时,我得到未定义的类use Socialite;

I tried composer dump-autoload and php artisan config:clear but nothing is working. 我尝试过composer dump-autoloadphp artisan config:clear但没有任何工作。 Am I doing something wrong? 难道我做错了什么?

I'm using Laravel 5.4 and Socialite 3.0 我正在使用Laravel 5.4和Socialite 3.0

Thanks! 谢谢!

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

This will clear the current compiled files, update the classes it needs and then write them back out so you don't have to do it again. 这将清除当前编译的文件,更新它所需的类,然后将它们写回,这样您就不必再这样做了。

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

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