Non-static method Tymon\JWTAuth\JWTAuth::attempt() should not be called statically
use TymonJWTAuthJWTAuth;
....
if (!$token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'invalid_credentials'], 401);
}
app.php
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
You need to
use JWTAuth;
instead of
use Tymon\JWTAuth\JWTAuth;
Because you have already added the JWTAuth alias to 'app.php'.
Take a look at the creating tokens examples.

Oh, are you using 1.0.0-beta or 0.5.11?
0.5.11
This works, then embarrasses the code highlighting
@sayber this is solved?
i have same problem please help
me too for 0.5.*
We offten use this
use Tymon\JWTAuth\JWTAuth;
In fact, it use this one
use Tymon\JWTAuth\Facades\JWTAuth;
I have config this in App.php ['aliases']
So, we instead
use Tymon\JWTAuth\JWTAuth;
to
use JWTAuth;
me too for 1.0.0.*
I have config this in APP.php ['aliases']
'JWTAuth' => TymonJWTAuthFacadesJWTAuth::class,
So,i instead
use TymonJWTAuthJWTAuth;
to
use JWTAuth;
but,it't not works!why?it tip me the JWTAuth is not defined
please instead configjwt..php : 'jwt' => 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter', as 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class , 'auth' => 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter' as 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class , 'storage' => 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter' as 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class
Most helpful comment
You need to
instead of
Because you have already added the
JWTAuthalias to 'app.php'.Take a look at the creating tokens examples.