PHPackages                             fachsimpeln/easyjwt - 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. fachsimpeln/easyjwt

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

fachsimpeln/easyjwt
===================

A easy-to-use implementation of of JWT Standard (JSON Web Tokens)

2.0.0(6y ago)220MITPHPPHP &gt;=7.1.0

Since Apr 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/fachsimpeln/EasyJWT)[ Packagist](https://packagist.org/packages/fachsimpeln/easyjwt)[ Docs](https://github.com/fachsimpeln/EasyJWT)[ RSS](/packages/fachsimpeln-easyjwt/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (3)Used By (0)

EasyJWT
=======

[](#easyjwt)

> An easy-to-use implementation of of JWT Standard (JSON Web Tokens)

What is JWT?
------------

[](#what-is-jwt)

JSON Web Token (JWT \[...\]) is an internet standard for creating JSON-based access tokens. \[...\] For example, a server could generate a token that has the claim "logged in as admin" and provide that to a client. The client could then use that token to prove that it is logged in as admin. The tokens can be signed by one party's private key (usually the server's) so that party can subsequently verify the token is legitimate. If the other party, by some suitable and trustworthy means, is in possession of the corresponding public key, they too are able to verify the token's legitimacy. The tokens are designed to be compact, URL-safe, and usable especially in a web-browser single-sign-on (SSO) context. JWT claims can typically be used to pass identity of authenticated users between an identity provider and a service provider, or any other type of claims as required by business processes.

~ taken from [Wikipedia](https://en.wikipedia.org/w/index.php?title=JSON_Web_Token&oldid=949805010)

Why EasyJWT?
------------

[](#why-easyjwt)

EasyJWT is intended to provide a version of JWT that is particularly easy to implement. So far only the easy to understand symmetric signing methods are used.

The library also supports the symmetric encryption of the JWT token with AES (using openssl), if confidential or sensitive information is to be stored in JWT.

[![PHP](https://camo.githubusercontent.com/13565be2943f9ac071d510da3fe9aa453dc63c3ed1004863947904c51235aa24/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6661636873696d70656c6e2f656173796a77743f636f6c6f723d253233343442453136)](https://php.net) [![Packagist](https://camo.githubusercontent.com/046aef6a6342c8223f55d87d082ac436c3b921ac8574aa97c6a20b1da57fd923/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6661636873696d70656c6e2f656173796a77742e737667)](https://packagist.org/packages/fachsimpeln/easyjwt) [![Packagist](https://camo.githubusercontent.com/abc321047b4bc06445ae3c491bd7aae3ee59af267fd18cbbd60525f074bd0a56/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6661636873696d70656c6e2f656173796a7774)](https://packagist.org/packages/fachsimpeln/easyjwt)

[![CodeFactor](https://camo.githubusercontent.com/8c79d37b43e9274be5ce6244824d5bad00f0e3323bc46cfba663a10dd5ee8bbd/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f6661636873696d70656c6e2f656173796a77742f6261646765)](https://www.codefactor.io/repository/github/fachsimpeln/easyjwt) [![License](https://camo.githubusercontent.com/03f8674d1dfea86294f1020f41bfcbad7a8ba4834ef57a464fbc3dff337addfa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6661636873696d70656c6e2f656173796a77743f636f6c6f723d253233303937414242)](https://github.com/fachsimpeln/EasyJWT/blob/master/LICENSE)

Install via Composer
--------------------

[](#install-via-composer)

```
composer require fachsimpeln/easyjwt
```

Install without Composer
------------------------

[](#install-without-composer)

1. Clone this repository
2. Include ./lib/JWT.inc.php

```
require __DIR__ . '/lib/JWT.inc.php';
```

Documentation
-------------

[](#documentation)

Usage documentation can be found in the [Wiki](https://github.com/fachsimpeln/EasyJWT/wiki). The documentation for the code can be found in [docs/](https://github.com/fachsimpeln/EasyJWT/tree/master/docs)

Supported Algorithms
--------------------

[](#supported-algorithms)

Signing AlgorithmWhat is this?HS256HMAC-SHA256HS384HMAC-SHA384HS512HMAC-SHA512nonenot recommendedEncryption AlgorithmWhat is this?AES-256-GCMOpenSSL AES EncryptionExample Code
------------

[](#example-code)

### Create a new JWT

[](#create-a-new-jwt)

```
// Sample array
$sample_array = array();
$sample_array['id'] = '0';
$sample_array['name'] = 'fachsimpeln';

// Reserved claims
$jwt_r_claims = new EasyJWT\JWTReservedClaims();

// Expire in 30 seconds
$jwt_r_claims->SetClaim('EXP', time() + 30);
// Be valid in 5 seconds, not immediately
$jwt_r_claims->SetClaim('NBF', time() + 5);

/* To overwrite an automatically set reserved claim
     $jwt_r_claims->SetClaim('ISS', 'localhost');
*/

// Options for the JWT (method)
$jwt_options = new EasyJWT\JWTOptions('HS512', $jwt_r_claims, true);

// Set data to JWTData object
$jwt_data = new EasyJWT\JWTData($sample_array, $jwt_options);
     /*
          For encryption:
          $jwt_data = new EasyJWT\JWTDataEncrypted($sample_array, $jwt_options);
     */

// Create new JWT object to interact with JWT
$jwt = new EasyJWT\JWT($jwt_data);

// Send the JWT as a cookie to the user's browser
$jwt->SetJWT(); // $jwt->toString();
```

### Read a JWT from cookies

[](#read-a-jwt-from-cookies)

```
// Read directly from cookie
$jwt_data = new EasyJWT\JWTData();
     /*
          Read from string ($value)
          $jwt_data = new EasyJWT\JWTData($value);

          For encryption:
          $jwt_data = new EasyJWT\JWTDataEncrypted();
          or
          $jwt_data = new EasyJWT\JWTDataEncrypted($enc_value);
     */

// Create new JWT object to validate signature, validate reserved claims and interact with JWT
$jwt = new EasyJWT\JWT($jwt_data);

// Check success (returns false when anything is invalid)
if ($jwt->IsValid()) {
     print 'Valid!';
} else {
     print 'Invalid!';
     die();
}

// Read main content (body) as array from JWT
     // Returns null on error
$sample_array = $jwt->GetData(); // $jwt->GetJWT(); $jwt->d();

// Show the contents of the JWT
var_dump($sample_array);
```

### More

[](#more)

These examples can also be found in the folder [sample/](https://github.com/fachsimpeln/EasyJWT/tree/master/sample)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

2

Last Release

2211d ago

Major Versions

1.0.0 → 2.0.02020-04-19

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35078533?v=4)[fachsimpeln](/maintainers/fachsimpeln)[@fachsimpeln](https://github.com/fachsimpeln)

---

Top Contributors

[![fachsimpeln](https://avatars.githubusercontent.com/u/35078533?v=4)](https://github.com/fachsimpeln "fachsimpeln (32 commits)")

---

Tags

accessautheasy-to-usejsonjwtphptokenjwtjsonAuthenticationtokenSimpleeasy

### Embed Badge

![Health badge](/badges/fachsimpeln-easyjwt/health.svg)

```
[![Health](https://phpackages.com/badges/fachsimpeln-easyjwt/health.svg)](https://phpackages.com/packages/fachsimpeln-easyjwt)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[rbdwllr/reallysimplejwt

A really simple library to generate user authentication JSON Web Tokens.

2902.4M22](/packages/rbdwllr-reallysimplejwt)[psecio/jwt

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

109352.2k2](/packages/psecio-jwt)[bizley/jwt

JWT integration for Yii 2

67425.3k2](/packages/bizley-jwt)[tuupola/branca

Authenticated and encrypted API tokens using modern crypto.

52309.2k1](/packages/tuupola-branca)[nowakowskir/php-jwt

JSON Web Token implementation for PHP.

41257.4k8](/packages/nowakowskir-php-jwt)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
