nixilla/php-jwt

Json Web Token for PHP

Installs: 18 587

Dependents: 0

Stars: 6

Watchers: 1

Forks: 149

Language: PHP

v0.1.1 2013-05-21 13:32 UTC

README

Travis

<?php
require_once './vendor/autoload.php';

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

Installation

{
    "require": {
        "nixilla/php-jwt": "dev-master"
    }
}

PHP-JWT

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

Example

<?php
require_once './vendor/autoload.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);
?>

Tests

Run the tests using phpunit:

git clone https://github.com/jwmickey/php-jwt.git && \
cd php-jwt && \
mkdir bin && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=bin && \
./bin/composer.phar install --dev && \
./bin/phpunit

License

3-Clause BSD.