I'm trying to login with tokens with the JWT library, I already have the composer installed and I'm guiding myself with the following example:
require_once 'vendor/autoload.php';
use Firebase\JWT\JWT;
$time = time();
$key = 'my_secret_key';
$token = array(
'iat' => $time, // Tiempo que inició el token
'exp' => $time + (60*60), // Tiempo que expirará el token (+1 hora)
'data' => [ // información del usuario
'id' => 1,
'name' => 'Eduardo'
]
);
$jwt = JWT::encode($token, $key);
$data = JWT::decode($jwt, $key, array('HS256'));
var_dump($data);
But I get the following error:
Fatal error: Uncaught Error: Class 'Firebase \ JWT \ JWT' not found in C: \ xampp \ htdocs \ webServiceMGRex \ query.php: 19 Stack trace: # 0 {main} thrown in C: \ xampp \ htdocs \ webServiceMGRex \ query.php on line 19
I do not know what I'm doing wrong, once you install the composer run this command line
composer requires firebase / php-jwt