简体   繁体   English

未找到 Laravel 级社交名媛

[英]Laravel Class Socialite not found

What I did:我做了什么:

  • Added "laravel/socialite": "~2.0" to composer.json添加"laravel/socialite": "~2.0"composer.json
  • Run composer update运行composer update
  • Added provider 'Laravel\\Socialite\\SocialiteServiceProvider' to app.phpapp.php添加了提供者'Laravel\\Socialite\\SocialiteServiceProvider'
  • Added alias 'Socialite' => 'Laravel\\Socialite\\Facades\\Socialite' to app.php添加别名'Socialite' => 'Laravel\\Socialite\\Facades\\Socialite'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'我仍然收到此错误: PHP Fatal error: Class '\\Socialite'

Edit编辑
composer dump-autoload fixed probably the error, but it's still not working correctly. composer dump-autoload可能修复了错误,但它仍然无法正常工作。

在您的控制器文件中添加

use Laravel\Socialite\Facades\Socialite;

Just below use Illuminate\\Http\\Request;就在下面use Illuminate\\Http\\Request; in your controller add use Socialize;在您的控制器中添加use Socialize;

Check if you have set your alias as "Socialize" as in the Socialite docs says to do this way:检查您是否已将别名设置为“社交”,如 Socialite 文档中所说的那样:

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

It as very confusing to me as well这对我来说也很困惑

I had the same issue.我遇到过同样的问题。 Clearing the config cache helped me in this situation:在这种情况下,清除配置缓存对我有帮助:

php artisan config:clear

First of all use ::class, on your config/app.php首先在你的 config/app.php 上使用::class,

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

Second, call the class in your controller其次,调用控制器中的类

use Socialite;

Third, try clear the config三、尝试清除配置

php artisan config:clear

And lastly check the redirect URL if its working最后检查重定向 URL 是否有效

http://yoursite.com/your_redirect

If anyone still encounters this problem even after trying above solutions, please clear the cache.如果尝试上述解决方案后仍有人遇到此问题,请清除缓存。 Most of the time classes and all are cached because of which this error occurs.大多数时间类和所有类都被缓存,因此会发生此错误。

php artisan config:clear

'Socialite' => 'Laravel\\Socialite\\Facades\\Socialite' is a mistake that I did too. 'Socialite' => 'Laravel\\Socialite\\Facades\\Socialite'也是我犯的一个错误。

It must be declared as 'Socialite' => Laravel\\Socialite\\Facades\\Socialite::class它必须声明为'Socialite' => Laravel\\Socialite\\Facades\\Socialite::class

I had the exact same problem and after the usual half hour of raging I realised that there was a trailing space at the end of my registration line ie我遇到了完全相同的问题,经过通常的半小时肆虐后,我意识到我的注册行末尾有一个尾随空格,即

'Laravel\\Socialite\\SocialiteServiceProvider ',

Once I'd removed the space funnily enough it worked!一旦我足够有趣地删除了空间,它就起作用了!

'Laravel\\Socialite\\SocialiteServiceProvider',

Once again the woes of copy and paste raise their ugly heads!复制和粘贴的困境再次抬起了他们丑陋的头!

在 Laravel 6 或更高版本中,尝试运行此命令

composer require laravel/socialite

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel - 没有找到“社交名媛” - Laravel - Class 'Socialite' not found 找不到laravel社会名流类ServiceProvider - laravel socialite class ServiceProvider not found 找不到 Laravel5 类“Laravel\\Socialite\\SocialiteServiceProvider” - Laravel5 Class 'Laravel\Socialite\SocialiteServiceProvider' not found Laravel / Socialite:类Laravel \\ Socialite \\ Contracts \\ Factory不存在 - Laravel/Socialite: Class Laravel\Socialite\Contracts\Factory does not exist ProviderRepository.php第146行中的FatalThrowableError:未找到类&#39;Laravel \\ Socialite \\ SocialiteServiceProvider&#39; - FatalThrowableError in ProviderRepository.php line 146: Class 'Laravel\Socialite\SocialiteServiceProvider' not found Spark Laravel 5.4中未定义的类社交名称 - Undefined class Socialite in Spark Laravel 5.4 laravel socialite google login / google auth,回调“404 not found” - laravel socialite google login / google auth, callback "404 not found" 无法将Laravel \\ Socialite \\ Two \\ User类的ErrorException对象转换为字符串 - ErrorException Object of class Laravel\Socialite\Two\User could not be converted to string Laravel Socialite : Laravel\\Socialite\\Two\\InvalidStateException - Laravel Socialite : Laravel\Socialite\Two\InvalidStateException Laravel 社交名流:Laravel\Socialite\Two\InvalidStateException - Laravel Socialite: Laravel\Socialite\Two\InvalidStateException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM