1
votes

I'm using this guide https://scotch.io/tutorials/token-based-authentication-for-angularjs-and-laravel-apps#installing-the-angularjs-dependencies to implement JWT-token, but when I come to the section where I want to test my API i get this error:

Class 'Tymon\JWTAuth\Providers\JWTAuthServiceProvider' not found

No matter which route I try to access this error pops up. I'm quite new at laravel so I can't figure out what is wrong, or what I'm not doing right - Thank you.

2
Check if the package has been installed successfully, if yes check that you have added the service provider in config/app.php, please post error log found under storage/logsKhan Shahrukh
Hi @KhanShahrukh, I followed exactly the guide. this is the error i get in the log:[2015-12-28 14:18:37] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Tymon\JWTAuth\Providers\JWTAuthServiceProvider' not found' in /var/www/opiioapp.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:146 Stack trace: #0 {main}Loc Dai Le

2 Answers

3
votes

For anyone who is finding this question from the scotch.io tutorial (excellent tutorial btw), the problem is that these lines:

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

Should be this (extra \):

'JWTAuth'   => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class
1
votes

I think you forgot to use facade

use Tymon\JWTAuth\Facades\JWTAuth;

Try adding this line at the top of your controller