jwt-auth: Unable to publish, Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found

Hi all,

I have installed “tymon/jwt-auth”:“1.0.0-beta.1” on Lararel 5.3.22. tymon folder was created under vendors folder, but I still received this message [RuntimeException] Could not scan for classes inside "tests/TestCase.php" which does not appear to be a file nor a folder

I have followed instructions in https://github.com/tymondesigns/jwt-auth/issues/513 and added Tymon\JWTAuth\Providers\LaravelServiceProvider::class in config/app.php file and tried to run php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider" but I receive this error:

[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found

LaravelServiceProvider.php file exists in the vendors folder. I have read all posts relating to this issue but most of them are regarding older versions and they suggests same thing want I already did. Am I doing something wrong? Could anybody give me some advise? Any help would be highly appreciated. Thanks

About this issue

Most upvoted comments

For Laravel 5.6 use the following steps:

change the service provider from:

Tymon\JWTAuth\Providers\LaravelServiceProvider::class,

to:

Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,

then publish it as:

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

Solution for Laravel 5.5:

Add library to composer.json:

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

Run this command in console: composer update

Add provider in config/app.php:

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

Add aliases in the same file `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 jwt:secret

And you can configure JWTAuth in next steps in: https://github.com/tymondesigns/jwt-auth/wiki/Configuration

changed Class ‘Tymon\JWTAuth\Providers\JWTAuthServiceProvider’ to Tymon\JWTAuth\Providers\LaravelServiceProvider::class

run: php artisan vendor:publish --provider=“Tymon\JWTAuth\Providers\LaravelServiceProvider”

Solution for Laravel 5.6:

1.) Add library to composer.json:

"require": {
    "tymon/jwt-auth": "1.0.0-rc.2"
 },

2.) Run this command in console:

$ composer update && composer install

3.) Remove any Tymon\JWT provider from config/app.php

4.) Delete Laravel Cache folders to remove old dependencies:

Delete the files in following folders: .../bootstrap/cache/services.php .../bootstrap/cache/config.php

5.) And then run those commands in console:

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

I had the same problem, I solved this way

I removed provider from ‘config/app.php’:

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

I removed aliases in the same file ‘config/app.php’:

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

I removed ‘tymon/jwt-aut’ from composer require and i runned command in console: composer update

I installed ‘tymon/jwt-aut’ with this command: composer require tymon/jwt-auth dev-develop

I added provider in ‘config/app.php’:

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

I published the package config file: php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

And generated a key: php artisan jwt:secret

Laravel Framework 5.8.16

I personnaly managed to cleanely install it by using "tymon/jwt-auth": "1.0.0-rc.1" in my composer.json. With Laravel 5.5.20.

Hope it helps!

@bachras I hit the same error. I removed all references to jwt-auth, then removed the package from composer, ran composer update. After success I added jwt-auth, tagged at 1.0.0-beta.2, ran composer update and then re-added references to app.php and ran composer update (just to be sure).

Finally, I ran: php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

Upgrade to the following for Laravel >5.5

"require-dev": { "tymon/jwt-auth": "1.0.*" },

See version compatibility here

i have the same problem as jwt-auth 0.5.12 doesnt create any

laravelServiceProvider

so kindly go to

\vendor\tymon\jwt-auth\src\Providers

and check for any

JWTAuthServiceProvider

and paste the .php file in

\app\Providers

and do composer update and then do the php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

Always getting In ProviderRepository.php line 208:

Class ‘Tymon\JWTAuth\Providers\LaravelServiceProvider’ not found in Laravel 5.6

For Laravel 5.7:

<h>

1) composer.json (note we need version 1.0.0-rc.3 for laravel 5.7)

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

2) update composer

composer update

3) publish vendor

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

4) generate key

php artisan jwt:secret

4) add aliases in config/app.php

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

@chrislow Thanks a lot! It worked for me 😃

Solution for Laravel 5.5:

Add library to composer.json:

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

Run this command in console: composer update

Add provider in config/app.php:

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

Add aliases in the same file `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 jwt:secret

And you can configure JWTAuth in next steps in: https://github.com/tymondesigns/jwt-auth/wiki/Configuration

Now in 2019, this work