firebasephp-jwt | php header jwt
AsimplelibrarytoencodeanddecodeJSONWebTokens(JWT)inPHP,conformingtoRFC7519[1].InstallationUsecomposertomanageyourdependenciesanddownloadPHP-JWT:composerrequirefirebase/php-jwtOptionally,installtheparagonie/sodium_compatpackagefromcomposerifyourphpis<7.2ordoesnothavelibsodiuminstalled:composerrequireparagonie/sodium_compatExampleuseFirebaseJWTJWT;$key="example_key";$payload=array("iss"=>"http://example.org","aud"=>"http://example.com","iat"=>1356999524,"nbf"=>1357000000);/***IM...
A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to RFC 7519[1].
InstallationUse composer to manage your dependencies and download PHP-JWT:
composer require firebase/php-jwtOptionally, install the paragonie/sodium_compat package from composer if your php is < 7.2 or does not have libsodium installed:
composer require paragonie/sodium_compat Example use FirebaseJWTJWT; $key = "example_key"; $payload = array( "iss" => "http://example.org", "aud" => "http://example.com", "iat" => 1356999524, "nbf" => 1357000000 ); /** * IMPORTANT: * You must specify supported algorithms for your application. See * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40 * for a list of spec-compliant algorithms. */ $jwt = JWT::encode($payload, $key); $decoded = JWT::decode($jwt, $key, array(HS256)); print_r($decoded); /* NOTE: This will now be an object instead of an associative array. To ...