Laravel Class Socialite not found

What I've done:

  • Added "laravel/socialite": "~2.0" to composer.json
  • Run composer update
  • Added provider 'Laravel\Socialite\SocialiteServiceProvider' in app.php
  • Added alias 'Socialite' => 'Laravel\Socialite\Facades\Socialite' to app.php

After all these steps, I created a new controller class that looks like this:

 <?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 bug fixed, but it still does not work.

+5
source share
10 answers

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

+7
source

Check if you set your alias as "Socialize" as stated in Socialite docs to do this:

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

This is also very embarrassing to me.

+6
source

In the Controllers file add

 use Laravel\Socialite\Facades\Socialite; 
+6
source

I had the same problem. Clearing the configuration cache helped me in this situation:

php artisan config:clear

+4
source

If someone is still experiencing this problem even after solving the above solutions, clear the cache. Most time classes and all are cached, which causes this error.

 php artisan config:clear 
+2
source

'Socialite' => 'Laravel\Socialite\Facades\Socialite' is a mistake I made too.

It should be declared as 'Socialite' => Laravel\Socialite\Facades\Socialite::class

+1
source

First of all use ::class, in your config / app.php

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

Secondly, call the class in your controller

 use Socialite; 

Third, try to clear the config

 php artisan config:clear 

And finally check the redirect URL if it works

 http://yoursite.com/your_redirect 
+1
source

I had the same problem, and after the usual half hour of rage, I realized that there was some kind of final place at the end of my registration line.

'Laravel\Socialite\SocialiteServiceProvider ',

Once I removed the space enough, it worked!

'Laravel\Socialite\SocialiteServiceProvider',

Once again, copy and paste problems raise their ugly heads!

0
source

To solve this problem.

So add this to config / app.php

"The supplier"

'Socialize' => 'Laravel \ Socialite \ SocialiteServiceProvider'

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

0
source

in laravel 6 or higher try this command

"composer requires Laravel / Socialite"

0
source

Source: https://habr.com/ru/post/1212901/


All Articles