Jwt configuration file not published after installation Jwt configuration file not published after installation laravel laravel

Jwt configuration file not published after installation


I had the same problem. The following worked for me:

php artisan config:clearphp artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class"php artisan config:cachephp artisan vendor:publish


To install the tymon/jwt-auth package in laravel, one should follow the following steps:

Composer.json require should be like this:

"require": {       "php": ">=5.5.9",       "laravel/framework": "5.1.*",       "tymon/jwt-auth": "0.5.*"   },

Then in config/app.php put the following in the providers array:

Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class

Then in the aliases array in the config/app.php add the following

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

Then type the following command:

php artisan vendor:publish

Note: Various tutorials will suggest you do the following :

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

However, before that, try the above command without --provider and it will work.

Then type:

php artisan jwt:generate

After this step, you can verify the generated key in app/config/jwt.php as mentioned below:

'secret' => env('JWT_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'),

Now, you are good to go...


I am posting this answer days after I solved the problem, since no answers are coming up.After some research I found that the main reason a config file may not be published despite correct installation is the due to confusion in the config:cache when new configs are added. However I solved the problem by running

php artisan config:clear

Then run the publish command again and boom!! it worked. This method will work not only for JWT but for other configurations that fail to publish but it is good to note that the problem can be caused by other things as well.