找不到 Laravel5 类“Laravel\Socialite\SocialiteServiceProvider”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32563066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:20:29  来源:igfitidea点击:

Laravel5 Class 'Laravel\Socialite\SocialiteServiceProvider' not found

phplaravellaravel-5composer-phplaravel-socialite

提问by brazorf

I've added

我已经添加

"laravel/socialite": "~2.0"

as a composer dependency, and i've added the service provider in my config/app.phpjust like this

作为作曲家的依赖项,我config/app.php像这样添加了服务提供者

'providers' => [
    // more providers
    'Laravel\Socialite\SocialiteServiceProvider'
]

Then, when i access to any of my application route, i've got this Class 'Laravel\Socialite\SocialiteServiceProvider' not foundexception.

然后,当我访问我的任何应用程序路由时,我遇到了这个Class 'Laravel\Socialite\SocialiteServiceProvider' not found异常。

Looking into my vendor/composer/autoload_psr4.phpi see there's not the Socialite mapping - ive ran composer updateand composer dump-autoloadmore than once.

展望我的vendor/composer/autoload_psr4.php我看有没有社交名媛映射-香港专业教育学院跑composer updatecomposer dump-autoload一次以上。

What's wrong?

怎么了?

采纳答案by ollieread

Did you run the composer command before adding the provider to the file? If not, this can sometimes cause issues.

在将提供程序添加到文件之前,您是否运行了 composer 命令?如果没有,这有时会导致问题。

I recommend removing the reference from the config file and the composer.json, then running composer request laravel/socialite 2.0. Also, just fyi, using the ::classnotation in the providers listing will help if you're using a full IDE like phpstorm, as it will highlight when it can't find the class.

我建议从配置文件和 composer.json 中删除引用,然后运行composer request laravel/socialite 2.0. 另外,仅供参考,::class如果您使用像 phpstorm 这样的完整 IDE ,使用提供者列表中的符号会有所帮助,因为它会在找不到类时突出显示。

回答by Mirza Obaid

first of all remove the line

首先删除该行

Laravel\Socialite\SocialiteServiceProvider::class,

and also

并且

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

from Config\app.php and update the composer by adding "laravel/socialite": "^2.0"and after that add these two line in Config\app.php it will work because when you add these lines before updating composer it goes to vender folder and search for the SocialiteProvider but it is not available yet so when you will update composer first and then add these lines it will work fine

从 Config\app.php 并通过添加 "laravel/socialite": "^2.0"和之后在 Config\app.php 中添加这两行来更新作曲家,它会起作用,因为当您在更新作曲家之前添加这些行时,它会转到供应商文件夹并搜索 SocialiteProvider 但它是尚不可用,因此当您首先更新作曲家然后添加这些行时,它会正常工作

回答by Vervaak Lai

I have removed the reference from the config file and the composer.json, then ran composer require laravel/socialite 2.0instead of composer request laravel/socialite 2.0.

我已经从配置文件和 composer.json 中删除了引用,然后运行 ​​composer requirelaravel/socialite 2.0而不是 composer requestlaravel/socialite 2.0.

Then add the following lines to the config file

然后将以下行添加到配置文件中

Laravel\Socialite\SocialiteServiceProvider::class,

and

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

回答by Fellipe Sanches

At first of all, check if your socialite package is compatible with your Laravel version.

首先,检查您的社交包是否与您的 Laravel 版本兼容。

You can verify your Laravel version inside your Laravel path, for it type:

您可以在 Laravel 路径中验证您的 Laravel 版本,输入:

$ php artisan --version

Then, check in the socialite Git repository (link below) a compatible version with your Laravel.

然后,在社交名流 Git 存储库(下面的链接)中检查与您的 Laravel 兼容的版本。

https://github.com/laravel/socialite/releases

https://github.com/laravel/socialite/releases

Now install the socialite package with composer require laravel/socialite x.x(where x.x is your socialite choosed version)

现在安装社交名流包composer require laravel/socialite x.x(其中 xx 是您选择的社交名流版本)

Lastly add the following lines in config/app.php file

最后在 config/app.php 文件中添加以下几行

inside 'providers' => [

在“提供者”中 => [

Laravel\Socialite\SocialiteServiceProvider::class,

and almost at the end of the file, inside 'aliases' => [

几乎在文件的末尾,在 'aliases' => [

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

Save the file.

保存文件。