Laravel 5.6.26错误-未找到类'Tymon \ JWTAuth \ Providers \ LaravelServiceProvider'

时间:2018-06-22 11:03:19

标签: php laravel

仅供参考,

我浏览了几个Web链接,找到了解决方案,例如更改/添加到 composer.json 文件

"tymon/jwt-auth": "^0.5.12" 
"tymon/jwt-auth": "^1.0.0-beta.3" 
"tymon/jwt-auth": "^1.0.0-rc.2"
使用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,
-----
]

composer update --no-scripts
composer update

发布时:

php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

下面的错误消息。

In ProviderRepository.php line 208:

  Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found

下面的撰写者更新输出

$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].

谢谢。

9 个答案:

答案 0 :(得分:5)

将库添加到composer.json:

"require": {
    ...
    "tymon/jwt-auth": "1.0.0-beta.3"
    ...
 },

在控制台中运行以下命令: 作曲家更新

在config / app.php中添加提供程序:

'providers' => [
    ...
    Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
    ...
],

在同一文件config / app.php中添加别名:

'aliases' => [
    ...
    'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
    'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
    ...
],

然后在控制台中运行命令: php artisan vendor:publish --provider =“ Tymon \ JWTAuth \ Providers \ LaravelServiceProvider” 下一次运行:

php artisan jwt:secret

答案 1 :(得分:4)

首先,由于您使用的是Laravel 5.6,因此需要具有此版本(1.0.0-rc.2作为最新的稳定版本),然后无需隐式键入提示服务提供商 >或外观的别名!图书馆本身将为您这样做。因此,请删除您添加到$providers$aliases数组中的内容。

然后确保运行:

composer dump-autoload -o

php artisan clear-compiled

如果您运行的Laravel低于5.6,请告诉我

答案 2 :(得分:3)

下载软件包时出现问题 尝试运行

composer require tymon/jwt-auth:dev-develop --prefer-source

并在config / app.php中将提供程序设置为

Tymon\JWTAuth\Providers\LaravelServiceProvider::class,

还提供别名:

'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,

完成上述所有步骤之后,发布您的供应商:

php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

并生成身份验证机密:php artisan jwt:secret

答案 3 :(得分:2)

我遇到这个问题已有一段时间了,这些答案对我都不起作用。经过努力解决问题后,我找到了解决方案。

如果您使用5.5以上的 laravel ,请尝试从下面的命令安装jwt-auth:

composer require tymon/jwt-auth:dev-develop --prefer-source

那么您将再没有问题

答案 4 :(得分:1)

运行:

composer require tymon/jwt-auth:dev-develop --prefer-source

答案 5 :(得分: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].

我的注意力集中在以下错误上

$composer require illuminate/auth
$composer update

所以,照亮/认证是麻烦的根源。

{
"userId":"rirani",
"jobTitleName":"Developer",
"firstName":"Romin",
"lastName":"Irani",
"preferredFullName":"Romin Irani",
"employeeCode":"E1",
"region":"CA",
"phoneNumber":"408-1234567",
"emailAddress":"romin.k.irani@gmail.com"
},
{
"userId":"nirani",
"jobTitleName":"Developer",
"firstName":"Neil",
"lastName":"Irani",
"preferredFullName":"Neil Irani",
"employeeCode":"E2",
"region":"CA",
"phoneNumber":"408-1111111",
"emailAddress":"neilrirani@gmail.com"
}
{
"userId":"thanks",
"jobTitleName":"Program Directory",
"firstName":"Tom",
"lastName":"Hanks",
"preferredFullName":"Tom Hanks",
"employeeCode":"E3",
"region":"CA",
"phoneNumber":"408-2222222",
"emailAddress":"tomhanks@gmail.com"
}

最终修复。

答案 6 :(得分:0)

将 Class 'Tymon\JWTAuth\Providers\JWTAuthServiceProvider' 更改为 Tymon\JWTAuth\Providers\LaravelServiceProvider::class

运行:php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

答案 7 :(得分:0)

试试这行代码,希望对你有帮助:

providers => [Tymon\JWTAuth\Providers\LaravelServiceProvider::class,],

要在 Laravel 中发布配置文件,您需要运行以下代码行:

php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

答案 8 :(得分:-1)

您可能还没有 JWT!

执行:

composer require tymon/jwt-auth

那么:

php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"