laravel 找不到 Tymon JWTAuth 类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35476045/
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
Tymon JWTAuth class not found
提问by Hamid
I want to use laravel for building api.
I installed JWTAuth from installation guide on wiki page. When I want to use vendor:publish
, I get this error:
我想使用 laravel 来构建 api。我从wiki 页面上的安装指南安装了 JWTAuth 。当我想使用时vendor:publish
,出现此错误:
After 3days searching on Google, I can not find a solution that working for me. How can I fix this?
在 Google 上搜索 3 天后,我找不到适合我的解决方案。我怎样才能解决这个问题?
回答by prince jose
For latest version. Please use following code in providers array in config file
对于最新版本。请在配置文件的提供者数组中使用以下代码
For laravel
对于laravel
Tymon\JWTAuth\Providers\LaravelServiceProvider::class
For Lumen : open app/Providers/AppServiceProvider.php and add the following to the register() method.
对于 Lumen :打开 app/Providers/AppServiceProvider.php 并将以下内容添加到 register() 方法中。
$this->app->register(\Tymon\JWTAuth\Providers\LumenServiceProvider::class);
Hope this will help someone.
希望这会帮助某人。
回答by Ali Zemani
add "tymon/jwt-auth": "^0.5.12"
to composer.json and command
添加"tymon/jwt-auth": "^0.5.12"
到 composer.json 和命令
composer update
on app/config.php add this to providers
在 app/config.php 上添加这个 providers
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
and on app/config.php add this on aliases
并在 app/config.php 上添加这个 aliases
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
tested on laravel 5.5
and tymon/jwt-auth": "^0.5.12"
测试laravel 5.5
和 tymon/jwt-auth": "^0.5.12"
回答by Emeka Mbah
Simply means you have not added JWTAuthServiceProvider
to list of Laravel Service providers.
只是意味着您尚未添加JWTAuthServiceProvider
到 Laravel 服务提供商列表中。
Go to config/app.php
and add JWTAuthServiceProvider
to providers list
转到config/app.php
并添加JWTAuthServiceProvider
到提供商列表
Like so:
像这样:
'providers' => [
...
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
...
]
Secondly since these error occurs only in console run:
其次,由于这些错误仅发生在控制台运行中:
composer update --no-scripts
composer update