Hamid
Hamid

Reputation: 2088

Tymon JWTAuth class not found

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: enter image description here

After 3days searching on Google, I can not find a solution that working for me. How can I fix this?

Upvotes: 2

Views: 14152

Answers (3)

Ali Zemani
Ali Zemani

Reputation: 141

add "tymon/jwt-auth": "^0.5.12" to composer.json and command

composer update 

on app/config.php add this to providers

Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,

and on app/config.php add this on 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"

Upvotes: 3

prince jose
prince jose

Reputation: 303

For latest version. Please use following code in providers array in config file

For laravel

Tymon\JWTAuth\Providers\LaravelServiceProvider::class

For Lumen : open app/Providers/AppServiceProvider.php and add the following to the register() method.

$this->app->register(\Tymon\JWTAuth\Providers\LumenServiceProvider::class);

Hope this will help someone.

Upvotes: 4

Emeka Mbah
Emeka Mbah

Reputation: 17520

Simply means you have not added JWTAuthServiceProvider to list of Laravel Service providers.

Go to config/app.php and add JWTAuthServiceProvider to providers list

Like so:

'providers' => [
   ...

   Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,

   ...
]

Secondly since these error occurs only in console run:

composer update --no-scripts
composer update

Upvotes: 3

Related Questions