Class 'Socialite' not found [duplicate]

2019-09-21 00:35发布

This question already has an answer here:

I am using Socialite package in my app. I followed all the instructions from the official github page. I am using Laravel 5.4.27. When I try to run the app, I get "Class 'Socialite' not found"error. What do I need to do??

I have also added use Socialite;, Laravel\Socialite\SocialiteServiceProvider::class, and 'Socialite' => Laravel\Socialite\Facades\Socialite::class, and I am using version 3 of socialite.

Here's the controller:

<?php

namespace App\Http\Controllers\Auth;

use Socialite;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class SocialLoginController extends Controller {

    public function redirectToProvider($service, Request $request) {
        return Socialite::driver($service)->redirect();
    }

    public function handleProviderCallback($service, Request $request) {

    }
}

What do I do?

1条回答
女痞
2楼-- · 2019-09-21 00:43

Try composer dump-autoload

composer install installs the vendor packages according to composer.lock (or creates composer.lock if not present),

composer update always regenerates composer.lock and installs the lastest versions of available packages based on composer.json

composer dump-autoload won’t download a thing. It just regenerates the list of all classes that need to be included in the project (autoload_classmap.php). Ideal for when you have a new class inside your project. Ideally, you execute composer dump-autoload -o , for a faster load of your webpages. The only reason it is not default, is because it takes a bit longer to generate (but is only slightly noticable)

EDIT:

Also clear the config cache:

php artisan config:clear

If all this stuff do not help, try this answer (find in old stack questions like "socialite not found"):

https://stackoverflow.com/a/28451747/7155723

Hope it will help you :)

查看更多
登录 后发表回答