PEAR package for JWT
PHP
Pull request Compare This branch is 4 commits ahead, 75 commits behind firebase:master.
Latest commit 3b8d7e3 Jan 14, 2015 Craig Slusher Changes interface and fixes tests
Permalink
Failed to load latest commit information.
Authentication
Exceptions
tests
.gitignore
.travis.yml
LICENSE
README.md
composer.json
package.xml
phpunit.xml.dist

README.md

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:

composer require firebase/php-jwt

Example

<?php

$key = "example_key";
$token = array(
    "iss" => "http://example.org",
    "aud" => "http://example.com",
    "iat" => 1356999524,
    "nbf" => 1357000000
);

$jwt = JWT::encode($token, $key);
$decoded = JWT::decode($jwt, $key);

print_r($decoded);

/*
 NOTE: This will now be an object instead of an associative array. To get
 an associative array, you will need to cast it as such:
*/

$decoded_array = (array) $decoded;

?>

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.