PHPackages                             anshu-krishna/php-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. anshu-krishna/php-jwt

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

anshu-krishna/php-jwt
=====================

A PHP library for JWT

3.2(11mo ago)0101MITPHPPHP &gt;=8.1

Since Feb 25Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/anshu-krishna/PHP-JWT)[ Packagist](https://packagist.org/packages/anshu-krishna/php-jwt)[ RSS](/packages/anshu-krishna-php-jwt/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (2)Versions (5)Used By (0)

JSON Web Token library for PHP
==============================

[](#json-web-token-library-for-php)

Installation:
-------------

[](#installation)

```
composer require anshu-krishna/php-jwt

```

- Generate JWT
- Verify JWT
- Supported Std Claims:
    - `iss`
    - `sub`
    - `aud`
    - `exp`
    - `nbf`
    - `iat`
    - `jti`
    - `kid`
- Supported Signature Algorithms:
    - `HS256`
    - `HS384`
    - `HS512`
    - `RS256`
    - `RS384`
    - `RS512`

Example (Basic):
----------------

[](#example-basic)

Read and verify JWT:

```
use Krishna\JWT\JWT;

$secret_key = 'your-secret';

$jwt = new JWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b2tlbi50ZXN0LmNvbSIsImF1ZCI6ImFwcC50ZXN0LmNvbSIsImlhdCI6MTY0Mzg5MTc1OCwibmJmIjoxNjQzODkxNzU4LCJleHAiOjE2NzI1MzQ4MDAsIm5hbWUiOiJBbnNodSBLcmlzaG5hIiwiY2l0eSI6IkJhbmdhbG9yZSIsImp0aSI6IjZmZGZhY2JkLWU1N2MtNDI1Yy1hNDBmLWM3NjQ5YjBkNDg0MSJ9.U7o6m77GP3oX_A_DgjgkS6U9rSLspPkOL_1dQLkr6QM');

var_dump(['JWT' => $jwt]);

echo "";
var_dump(['Verify' => $jwt->verify($secret_key)]);
```

Output:

```
...file_path...\index.php:50:
array (size=1)
  'JWT' =>
    object(Krishna\JWT\JWT)[3]
      public 'enc' => string 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b2tlbi50ZXN0LmNvbSIsImF1ZCI6ImFwcC50ZXN0LmNvbSIsImlhdCI6MTY0Mzg5MTc1OCwibmJmIjoxNjQzODkxNzU4LCJleHAiOjE2NzI1MzQ4MDAsIm5hbWUiOiJBbnNodSBLcmlzaG5hIiwiY2l0eSI6IkJhbmdhbG9yZSIsImp0aSI6IjZmZGZhY2JkLWU1N2MtNDI1Yy1hNDBmLWM3NjQ5YjBkNDg0MSJ9' (length=281)
      public 'sig' => string 'S�:���?z��Â8$K�=�"��/]@�+��' (length=32)
      public 'head' =>
        array (size=2)
          'alg' => string 'HS256' (length=5)
          'typ' => string 'JWT' (length=3)
      public 'body' =>
        array (size=8)
          'iss' => string 'token.test.com' (length=14)
          'aud' => string 'app.test.com' (length=12)
          'exp' => int 1672534800
          'nbf' => int 1643891758
          'iat' => int 1643891758
          'jti' => string '6fdfacbd-e57c-425c-a40f-c7649b0d4841' (length=36)
          'name' => string 'Anshu Krishna' (length=13)
          'city' => string 'Bangalore' (length=9)

...file_path...\index.php:53:
array (size=1)
  'Verify' =>
    object(Krishna\DataValidator\Returner)[26]
      public readonly mixed 'value' => boolean true
      public readonly mixed 'error' => null
      public readonly bool 'valid' => boolean true

```

Create JWT:

```
use Krishna\JWT\Algo;
use Krishna\JWT\JWT;

$secret_key = 'your-secret';

$jwt = new JWT;

$jwt['name'] = 'AK';
$jwt['country'] = 'India';

$jwt->sign($secret_key, Algo::HS512);

echo "Token: ", $jwt, "";

var_dump($jwt);
```

Output:

```
Token: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiQUsiLCJjb3VudHJ5IjoiSW5kaWEiLCJpYXQiOjE2NDU3NzU3MDUsIm5iZiI6MTY0NTc3NTcwNSwiaXNzIjoidGVzdC5zZXJ2ZXIiLCJleHAiOjE2NDU3NzYzMDUsImp0aSI6IjI5YWUyZTJmLTM0NGMtNDcyMy05OWMwLTMzZWEyNzRmMDMxMSJ9.pBqcBMMjeCtpzW1EarehRwsk-hBbZmZr0z1uwPii0oITsCiZ8orPIEjGgHIPC9jesd3AqoxOuCXUdA-MXhy05w

...file_path...\index.php:57:
object(Krishna\JWT\JWT)[3]
  public 'enc' => string 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiQUsiLCJjb3VudHJ5IjoiSW5kaWEiLCJpYXQiOjE2NDU3NzU3MDUsIm5iZiI6MTY0NTc3NTcwNSwiaXNzIjoidGVzdC5zZXJ2ZXIiLCJleHAiOjE2NDU3NzYzMDUsImp0aSI6IjI5YWUyZTJmLTM0NGMtNDcyMy05OWMwLTMzZWEyNzRmMDMxMSJ9' (length=233)
  public 'sig' => string '�����#x+i�mDj��G�$�[ffk�=n��҂��(��� Hƀr���ޱ����N�%�t��^���' (length=64)
  public 'head' =>
    array (size=2)
      'alg' => string 'HS512' (length=5)
      'typ' => string 'JWT' (length=3)
  public 'body' =>
    array (size=7)
      'name' => string 'AK' (length=2)
      'country' => string 'India' (length=5)
      'iat' => int 1645775705
      'nbf' => int 1645775705
      'iss' => string 'test.server' (length=11)
      'exp' => int 1645776305
      'jti' => string '29ae2e2f-344c-4723-99c0-33ea274f0311' (length=36)

```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance50

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~411 days

Total

4

Last Release

355d ago

Major Versions

2.0 → 3.02022-02-25

PHP version history (2 changes)2.0PHP &gt;=8.0.0

3.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c583afac6200755c7e2326c965ef0fcc382f4f7448f9459af6732358fc0b7fb?d=identicon)[anshu-krishna](/maintainers/anshu-krishna)

---

Top Contributors

[![anshu-krishna](https://avatars.githubusercontent.com/u/4680045?v=4)](https://github.com/anshu-krishna "anshu-krishna (7 commits)")

---

Tags

jwtjwt-tokensphpphp81phpjwt

### Embed Badge

![Health badge](/badges/anshu-krishna-php-jwt/health.svg)

```
[![Health](https://phpackages.com/badges/anshu-krishna-php-jwt/health.svg)](https://phpackages.com/packages/anshu-krishna-php-jwt)
```

###  Alternatives

[griffinledingham/php-apple-signin

A simple library to decode and parse Apple Sign In client tokens.

2052.1M1](/packages/griffinledingham-php-apple-signin)[hyperf-ext/jwt

The Hyperf JWT package.

53140.6k2](/packages/hyperf-ext-jwt)[maicol07/flarum-ext-sso

SSO for Flarum

468.7k](/packages/maicol07-flarum-ext-sso)

PHPackages © 2026

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