PHPackages                             xaamin/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. xaamin/jwt

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

xaamin/jwt
==========

PHP Implementation of JSON Web token with RSA

v2.0.2(2y ago)29.9k1MITPHPPHP ^7.2 || ^8.0

Since Sep 12Pushed 2y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (8)Used By (0)

PHP JWT Tokens with RSA Support
===============================

[](#php-jwt-tokens-with-rsa-support)

PHP Implementation of JSON Web token with RSA.

Supported algorithms:
---------------------

[](#supported-algorithms)

```
RSA (Public Key/Private Key pair)

RS256 - RSA using SHA-256 hash algorithm
RS384 - RSA using SHA-384 hash algorithm
RS512 - RSA using SHA-512 hash algorithm

HMAC algorithms :

HS256 - HMAC using SHA-256 hash algorithm (default)
HS384 - HMAC using SHA-384 hash algorithm
HS512 - HMAC using SHA-512 hash algorithm

```

Install
-------

[](#install)

With composer

```
composer require xaamin/jwt

```

How to use with RSA public/private key
======================================

[](#how-to-use-with-rsa-publicprivate-key)

Set configuration in **src/Config/config.php**. Don't use key provided here in production.

```
    'algorithm' => 'RS512',

    // ... Other stuff here

    'keys' => [
        'public' => '../keys/public_key.pem',
        'private' => '../keys/private_key.pem',

        'passphrase' => null,
    ],

```

```
	$payload = [
			'sub'   => 1,
			'username' => 'xaamin'
	    ];

	// Generate token
	$token = Xaamin\JWT\Facade\Native\JWT::encode($payload);

	// Verify the token
	try{
		$token = Xaamin\JWT\Facade\Native\JWT::decode($token->get());

	    var_dump($token);
	} catch (Exception $e) {
		echo $e->getMessage();
	}
```

How to use with HMAC
--------------------

[](#how-to-use-with-hmac)

Set configuration in **src/Config/config.php**

```
    'algorithm' => 'HS512',

    'secret' => 'some-random-string'

```

```
	$payload = [
			'sub'   => 1,
			'username' => 'xaamin'
	    ];

	// Generate token
	$token = Xaamin\JWT\Facade\Native\JWT::encode($payload);

	// Verify the token
	try{
		$token = Xaamin\JWT\Facade\Native\JWT::decode($token->get());

	    var_dump($token);
	} catch (Exception $e) {
		echo $e->getMessage();
	}
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% 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 ~452 days

Recently: every ~586 days

Total

7

Last Release

825d ago

Major Versions

1.x-dev → v2.02023-04-27

PHP version history (2 changes)v1.0.1PHP &gt;=5.4

v2.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab0364ad60f3e9bba208eb33c139b10281bbead4d267ce0fbd8ed50338174e30?d=identicon)[xaamin](/maintainers/xaamin)

---

Top Contributors

[![benxaamin](https://avatars.githubusercontent.com/u/21373088?v=4)](https://github.com/benxaamin "benxaamin (12 commits)")[![xaamin](https://avatars.githubusercontent.com/u/4313256?v=4)](https://github.com/xaamin "xaamin (1 commits)")

---

Tags

jwttokenlaravel jwt

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/xaamin-jwt/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[adhocore/jwt

Ultra lightweight JSON web token (JWT) library for PHP5.5+.

3031.6M15](/packages/adhocore-jwt)[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)[miladrahimi/php-jwt

A PHP implementation of JWT (JSON Web Token) generator, parser, verifier, and validator

70263.2k2](/packages/miladrahimi-php-jwt)[tuupola/branca

Authenticated and encrypted API tokens using modern crypto.

52309.2k1](/packages/tuupola-branca)

PHPackages © 2026

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