Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Class Socialite not found

What I did:

  • Added "laravel/socialite": "~2.0" to composer.json
  • Run composer update
  • Added provider 'Laravel\Socialite\SocialiteServiceProvider' to app.php
  • Added alias 'Socialite' => 'Laravel\Socialite\Facades\Socialite' to app.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.

like image 287
Sylnois Avatar asked Feb 08 '15 14:02

Sylnois


4 Answers

In your Controllers file add

use Laravel\Socialite\Facades\Socialite;
like image 150
Shakhawat Avatar answered Nov 08 '22 21:11

Shakhawat


Just below use Illuminate\Http\Request; in your controller add use Socialize;

like image 7
Chrisx Avatar answered Nov 08 '22 21:11

Chrisx


Check if you have set your alias as "Socialize" as in the Socialite docs says to do this way:

'Socialize' => 'Laravel\Socialite\Facades\Socialite',

It as very confusing to me as well

like image 6
Israel Ortuño Avatar answered Nov 08 '22 20:11

Israel Ortuño


I had the same issue. Clearing the config cache helped me in this situation:

php artisan config:clear

like image 5
Juergen Kraus Avatar answered Nov 08 '22 21:11

Juergen Kraus