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

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

gamegos/jwt
===========

Json Web Token (JWT) PHP implementation

0.1.1(11y ago)1762.1k↓32.2%5MITPHPPHP &gt;=5.4

Since Aug 19Pushed 3y ago18 watchersCompare

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

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

PHP JSON Web Token (JWT) Library
================================

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

JSON Web Token (JWT) implementation based on [draft-ietf-oauth-json-web-token-25](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25).

Installation
------------

[](#installation)

The recommended way to install gamegos/jws is through [Composer](http://getcomposer.org).

```
{
    "require": {
        "gamegos/jwt": "~0.1"
    }
}
```

Basic Usage
-----------

[](#basic-usage)

Encoding

```
$key = 'some-secret-for-hmac';
$alg = 'HS256';

$token = new \Gamegos\JWT\Token();
$token->setClaim('sub', 'someone@example.com'); // alternatively you can use $token->setSubject('someone@example.com') method
$token->setClaim('exp', time() + 60*5);

$encoder = new \Gamegos\JWT\Encoder();
$encoder->encode($token, $key, $alg);

printf("JWT TOKEN: %s\n", $token->getJWT()); //eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzb21lb25lQGV4YW1wbGUuY29tIiwiZXhwIjoxNDA4NDUzNzkwfQ.2Fk5-UUMhOAcQH812LL0sdaf29zuf293nLhHp_VKBDg
```

Validation

```
$jwtString = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzb21lb25lQGV4YW1wbGUuY29tIiwiZXhwIjoxNDA4NDUyMzcxfQ.Fy1DLdfZBiR_khyTsghItDW3_1rM7osz_IxjiaiRto0';

$key = 'some-secret-for-hmac';

try {
    $validator = new \Gamegos\JWT\Validator();
    $token = $validator->validate($jwtString, $key);

    print_r($token->getClaims());
    print_r($token->getHeaders());
} catch (\Gamegos\JWT\Exception\JWTException $e) {
    printf("Invalid Token:\n  %s\n", $e->getMessage());
    //$e->getToken();
}
```

See [examples](https://github.com/Gamegos/php-jwt/tree/master/examples) folder for sample code.

Supported Signature Algorithms
------------------------------

[](#supported-signature-algorithms)

This package uses `gamegos/jws` for signing tokens. Currently supported signature and mac algorithms:

- *HS256*, *HS384*, *HS512* (HMAC using SHA-XXX)
- *RS256*, *RS384*, *RS512* (RSASSA-PKCS-v1\_5 using SHA-XXX)

Details can be found [here.](https://github.com/Gamegos/php-jws#algorithms)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

4058d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5402895fce341eb0254bd5312d8458d6c85e28cb5f088a6d7f962d4ea4047f0a?d=identicon)[glkz](/maintainers/glkz)

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

---

Top Contributors

[![glkz](https://avatars.githubusercontent.com/u/281635?v=4)](https://github.com/glkz "glkz (8 commits)")

---

Tags

jwtJWSJSON Web Tokenjson token

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

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

A simple library to work with JSON Web Token and JSON Web Signature

7.5k316.6M895](/packages/lcobucci-jwt)[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[web-token/jwt-framework

JSON Object Signing and Encryption library for PHP and Symfony Bundle.

94818.9M77](/packages/web-token-jwt-framework)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40820.2M68](/packages/auth0-auth0-php)

PHPackages © 2026

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