Laravel 5.6.26 错误 - 未找到类“Tymon\JWTAuth\Providers\LaravelServiceProvider”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50986513/
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
Laravel 5.6.26 Error- Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found
提问by Goron
FYI,
供参考,
I have gone through several web links and found solutions like changing/adding to composer.jsonfile
我浏览了几个网络链接并找到了解决方案,例如更改/添加到composer.json文件
"tymon/jwt-auth": "^0.5.12"
"tymon/jwt-auth": "^1.0.0-beta.3"
"tymon/jwt-auth": "^1.0.0-rc.2"
app.phpconfig file with LaravelServiceProvider/JWTAuthServiceProvider
带有 LaravelServiceProvider/JWTAuthServiceProvider 的app.php配置文件
providers => [
---
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
---
]
aliases => [
-----
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
-----
]
And
和
composer update --no-scripts
composer update
When publishing:
发布时:
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
Error message below.
下面的错误信息。
In ProviderRepository.php line 208:
Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found
composer update output below
作曲家更新输出如下
$composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: remove laravel/framework v5.6.26
- Conclusion: don't install laravel/framework v5.6.26
- Installation request for tymon/jwt-auth 1.0.0-beta.3 -> satisfiable by tymon/jwt-auth[1.0.0-beta.3].
- Conclusion: don't install laravel/framework v5.6.1
- Conclusion: don't install laravel/framework v5.6.0
- tymon/jwt-auth 1.0.0-beta.3 requires illuminate/auth 5.1.* || 5.2.* || 5.3.* || 5.4.* -> satisfiable by illuminate/auth[5.1.x-dev].
- Installation request for laravel/framework 5.6.* -> satisfiable by laravel/framework[5.6.x-dev].
Thanks in advance.
提前致谢。
回答by Mohamed Kawsara
First of all, since you are using Laravel 5.6 you need to have this version (1.0.0-rc.2
as the newest stable version), then there is no need to implicitly type hint the service provideror the alias for its facade! the library itself shall do so for you. So please remove what you've added to $providers
& $aliases
arrays.
首先,由于您使用的是 Laravel 5.6,因此您需要拥有此版本(1.0.0-rc.2
作为最新的稳定版本),因此无需隐式类型提示服务提供者或其外观的别名!图书馆本身会为你这样做。因此,请删除您添加到$providers
&$aliases
数组中的内容。
Then make sure to run:
然后确保运行:
composer dump-autoload -o
composer dump-autoload -o
and
和
php artisan clear-compiled
php artisan clear-compiled
If you are running less than 5.6 for Laravel, let me know
如果你运行的 Laravel 低于 5.6,请告诉我
回答by Sachin Ingale
Add library to composer.json:
将库添加到 composer.json:
"require": {
...
"tymon/jwt-auth": "1.0.0-beta.3"
...
},
Run this command in console: composer update
在控制台中运行此命令:composer update
Add provider in config/app.php:
在 config/app.php 中添加提供者:
'providers' => [
...
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
...
],
Add aliases in the same file `config/app.php':
在同一个文件 `config/app.php' 中添加别名:
'aliases' => [
...
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
...
],
And then run command in console: php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider" next run:
然后在控制台中运行命令: php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider" 接下来运行:
php artisan jwt:secret
回答by Amas
i've had this problem for a while and none these answers worked for me. after struggling with problem i found a solution.
我遇到这个问题已经有一段时间了,这些答案都不适合我。在遇到问题后,我找到了解决方案。
try installing jwt-auth from command below if you use laravel above 5.5:
如果您使用5.5 以上的 laravel,请尝试从下面的命令安装 jwt-auth :
composer require tymon/jwt-auth:dev-develop --prefer-source
then you will have no problem anymore
那么你就没有问题了
回答by Divyesh pal
There is some problem while downloading the package Try running
下载包时出现问题 尝试运行
composer require tymon/jwt-auth:dev-develop --prefer-source
and in your config/app.php make providers as
并在您的 config/app.php 中将提供者设为
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
Also provide the Aliases as:
还提供别名为:
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
After all the above steps publish your vendor:
完成上述所有步骤后,发布您的供应商:
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
And generate auth secret : php artisan jwt:secret
并生成身份验证秘密: php artisan jwt:secret
回答by user3767183
Run:
跑:
composer require tymon/jwt-auth:dev-develop --prefer-source