PHPackages                             psecio/jwt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. psecio/jwt

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

psecio/jwt
==========

A JWT (JSON Web Token) Encoding &amp; Decoding library

1.7(11y ago)109352.2k↑22%13[9 issues](https://github.com/psecio/jwt/issues)2MITPHPPHP &gt;=5.4.0

Since Jul 13Pushed 10y ago9 watchersCompare

[ Source](https://github.com/psecio/jwt)[ Packagist](https://packagist.org/packages/psecio/jwt)[ Docs](https://github.com/psecio/jwt.git)[ RSS](/packages/psecio-jwt/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (9)Used By (2)

JWT (JSON Web Token) Creation and Decoding Library
==================================================

[](#jwt-json-web-token-creation-and-decoding-library)

[![Build Status](https://camo.githubusercontent.com/bbea89dee70b802df5c807d25a87e1164babf036a94bd2e4c925f3b80074b824/68747470733a2f2f7472617669732d63692e6f72672f70736563696f2f6a77742e7376673f6272616e63683d6d6173746572)](http://travis-ci.org/psecio/jwt)

This library allows for the creation and decoding of JWT (JSON Web Tokens).

### Installation

[](#installation)

This tool can be installed via Composer:

```
{
	"require": {
		"psecio/jwt": "1.*"
	}
}

```

### Example Usage

[](#example-usage)

In the example below, the `JWT` object is created and a `Header` instance is assigned (required). The `JWt` object is then assigned several claims: issuer, audience, issued at and not before to define data and how it could be processed. The `encode`method is then called with the `key` and a resulting JWT-formatted string is returned.

**NOTE:** The JWT token will be generated in the order the claims are provided. No sorting is done in the background.

The `decode` method can then be called on the data along with the `key` to return an object matching the state of the `jwt` object.

```
