'Socialite not reconize
i have tried everythings i found online but nothing seems to work.. Here is my problem: I tried to implement authentification with google in laravel using socialite but i have follewed thoses steps describes: here
here is my composer.json:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"jeroennoten/laravel-adminlte": "^3.7",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/socialite": "^5.5",
"laravel/tinker": "^2.5",
"laravel/ui": "^3.4"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
'providers' => [
//...
Laravel\Socialite\SocialiteServiceProvider::class,
//...
],
'aliases' => [
//..
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
//...
],
here is my controller, that's where i get my error, on this line "Socialite::driver($provider)->redirect()":
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Socialite;
class SocialiteController extends Controller
{
protected $providers = ["google"];
public function loginRegister(){
return view ("socialite.login-register");
}
public function redirect (Request $rq){
$provider = $rq->provider;
if(in_array($provider,$this->providers)){
return Socialite::driver($provider)->redirect();
}
}
}
here is a screenshoot of the error:

laravel doesn't find anywhere the facade socialite even when i tried to import it manually like that =>"Laravel\Socialite\Facades\Socialite" .. i tried to download again the package and tried also some cmd like composer dump-autoload.., to try regenerates the list of all classes that need to be included in the project but it' won't work. Thanks in advance for any advices and help.
Solution 1:[1]
As the error says, it does not find the package Socialite. Try to add the use of the package at the beginning of your controller:
use Laravel\Socialite\Facades\Socialite;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mátyás Gr?ger |
