Skip to content

brandonlamb/php-jwt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

PHP-JWT

A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec

Installation

Use composer to manage your dependencies and download PHP-JWT:

php composer require brandonlamb/php-jwt

Example

<?php

$token = new Jwt\Token();
$token
	->setKey('app_key')
	->setClaim('iss', 'http://example.com')
	->setClaim('aud', 'http://example.com')
	->setClaim('iat', 1356999524)
	->setClaim('nbf', 1357000000);

$jwt = Jwt\Writer::encode($token);
$jwt = Jwt\Writer::encode($token, 'app_key', 'HS256');

$token = Jwt\Reader::decode($jwt, 'app_key');

print_r($token);
?>

Tests

Run the tests using phpunit:

$ pear install PHPUnit
$ phpunit --configuration phpunit.xml.dist
PHPUnit 3.7.10 by Sebastian Bergmann.
.....
Time: 0 seconds, Memory: 2.50Mb
OK (5 tests, 5 assertions)

License

3-Clause BSD.

About

PEAR package for JWT

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%