skip to Main Content

I’m getting this weird error. Although i have performed the required steps of installing the "Socialite" package , for instance i have edit the "providers" and "aliases" in "config/app.php". Thing is I’m using this in existing project, but when i created in fresh copy it was working fine.

Undefined type ‘LaravelSocialiteFacadesSocialite’.intelephense(1009)

Here is my controller code (Where i’m getting this error)

   `// Google Registration 

   public function googleRedirect()
   {
   return Socialite::driver('google')->redirect();
   }

   public function loginWithGoogle()
   {
        try
       {
         $user = Socialite::driver('google')->user();
         $existingUser = User::where('google_id',$user->id)->first();

         if($existingUser)
         {
                 Auth::login($existingUser);
                 return redirect('/home');
         }
  
         else{
                $createUser = User::create([
                        $uuid = Str::uuid()->toString(),
                        'name'      =>  $user->name,
                        'email'     =>  $user->email,
                        'google_id' =>  $user->id,
                ]);
       
               Auth::login($createUser);
               return redirect('/timeline');
           }
       }
   catch(Throwable $th){
   throw $th;
   }
   }

`

PS* I have already imported the required package on the top

use IlluminateSupportFacadesAuth;
use LaravelSocialiteFacadesSocialite;

I have followed all the required steps to install the socialite package, only problem that i’m facing is getting following error in controller:

Undefined type 'LaravelSocialiteFacadesSocialite'.intelephense(1009)

PS* I’m using Laravel 9.

2

Answers


  1. The main reason would that you forgot to include the classes in your class. But you did. Then i would try this two commands:

    1. php artisan config:clear
    2. composer dump-autoload
    
    Login or Signup to reply.
  2. i review your code use Socialite::driver(‘google’)->stateless()->user(); this instead of Socialite::driver(‘google’)->user();

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search