Skip to content

50onRed/php-jwt

This branch is 4 commits ahead of, 221 commits behind firebase/php-jwt:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Craig Slusher
Jan 14, 2015
3b8d7e3 · Jan 14, 2015

History

68 Commits
Jan 14, 2015
Nov 14, 2014
Jan 14, 2015
Nov 13, 2014
Nov 13, 2014
Dec 31, 2012
Oct 23, 2014
Jan 13, 2015
Jun 28, 2013
Aug 30, 2013

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:

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.

Packages

No packages published

Languages

  • PHP 100.0%