What I did:
- Added
"laravel/socialite": "~2.0"
tocomposer.json
- Run
composer update
- Added provider
'Laravel\Socialite\SocialiteServiceProvider'
toapp.php
- Added alias
'Socialite' => 'Laravel\Socialite\Facades\Socialite'
toapp.php
After all this steps I created a new Controller Class which looks like that:
<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class AuthController extends Controller {
public function login()
{
return \Socialite::with('facebook')->redirect();
}
}
But i still got this error: PHP Fatal error: Class '\Socialite'
Edit
composer dump-autoload
fixed probably the error, but it's still not working correctly.
'Socialite' => 'Laravel\Socialite\Facades\Socialite'
is a mistake that I did too.It must be declared as
'Socialite' => Laravel\Socialite\Facades\Socialite::class
Check if you have set your alias as "Socialize" as in the Socialite docs says to do this way:
It as very confusing to me as well
First of all use
::class,
on your config/app.phpSecond, call the class in your controller
Third, try clear the config
And lastly check the redirect URL if its working
In your Controllers file add
Just below
use Illuminate\Http\Request;
in your controller adduse Socialize;
I had the same issue. Clearing the config cache helped me in this situation:
php artisan config:clear