Tymon JWTAuth class not found

11,849

Solution 1

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

Solution 2

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.

Solution 3

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"

Share:
11,849
Hamid
Author by

Hamid

Cooking mobile stuff with JavaScript, TypeScript, react-native and Swift

Updated on August 12, 2022

Comments

  • Hamid
    Hamid over 1 year

    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?

  • Hamid
    Hamid about 8 years
    I added this before. I think my problem is related to composer auto loader and maybe it's not working. How can I find composer auto load files work correctly?
  • Hamid
    Hamid about 8 years
    Thank you @Digitlimit but still I have problem :\
  • Emeka Mbah
    Emeka Mbah about 8 years
    You need to verify Tymon\AUth service provider is in vendor/jwt-auth/src/providers
  • Hamid
    Hamid about 8 years
    YES! Thank you @Digitlimit my problem was in my folders structure.
  • pixelworlds
    pixelworlds almost 7 years
    I get the following error (using Laravel 5.4) after adding the provider. Class 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter' not found
  • Toby Speight
    Toby Speight over 6 years
    Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and in what way it differs from the current accepted answer. Please edit your answer to add some explanation, including the assumptions you've made.
  • Vrian7
    Vrian7 over 4 years
    Working on laravel 5.8