Spark Laravel 5.4

时间:2017-08-03 17:04:58

标签: php laravel-5.4 laravel-socialite laravel-spark

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

在我的供应商中,我添加了

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;

时,我得到未定义的类社交名称

我尝试了composer dump-autoloadphp artisan config:clear,但没有任何效果。我做错了吗?

我正在使用Laravel 5.4和Socialite 3.0

谢谢!

1 个答案:

答案 0 :(得分:0)

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

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