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

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

lostinvlg/jwt
=============

Simple JWT Builder and Parser

v1.0.0(4y ago)150MITPHPPHP ^8.0

Since Mar 16Pushed 4y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

PHP JWT
=======

[](#php-jwt)

A simple library to encode and decode [JWT](https://jwt.io/) tokens in PHP (conforming to [RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519))

Dependencies
------------

[](#dependencies)

- PHP 8.0+
- OpenSSL Extension
- [firebase/php-jwt](https://github.com/firebase/php-jwt)

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

[](#installation)

```
composer require lostinvlg/jwt
```

Creating jwt
------------

[](#creating-jwt)

```
use Lostinvlg\Jwt\Algorithm;
use Lostinvlg\Jwt\Jwt;
use Lostinvlg\Jwt\Key;

$jwtId = '1dA8dDQ5lE';
$time = time();
$jwt = new Jwt();

$token = $jwt
    ->getBuilder()
    ->setKey(new Key('YOUR_SECRET_KEY_STRING', Algorithm::HS256))
    ->setIssuedBy('https://example.com')
    ->setAudience('https://example.com')
    ->setIssuedAt($time)
    ->setNotBefore($time + 10)
    ->setExpiresAt($time + 3600)
    ->setIdentifiedBy($jwtId)
    ->setClaim('user_id', 1)
    ->setClaim('role_id', 'admin')
    ->getToken();

$encoded = (string) $token; // contains jwt encoded string

$token->getClaim('user_id'); // equals 1
$token->getClaim('role_id'); // equals "admin"
$token->getClaim('exp'); // returns expires timestamp
```

Parsing from string
-------------------

[](#parsing-from-string)

```
use Lostinvlg\Jwt\Algorithm;
use Lostinvlg\Jwt\Jwt;
use Lostinvlg\Jwt\Key;

$jwt = new Jwt();
$token = $jwt->getParser(new Key('YOUR_SECRET_KEY_STRING', Algorithm::HS256))->parse($encoded);

$token->getClaim('user_id'); // equals 1
$token->getClaim('role_id'); // equals "admin"
$token->getClaim('exp'); // returns expires timestamp
```

License
-------

[](#license)

[MIT](https://opensource.org/licenses/MIT)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

1516d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6015d4a22edf4ec362b85d8b362081f58fec399ed9deb172e6e0f7935245b0ff?d=identicon)[lostinvlg](/maintainers/lostinvlg)

---

Top Contributors

[![lostinvlg](https://avatars.githubusercontent.com/u/13403087?v=4)](https://github.com/lostinvlg "lostinvlg (7 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[robsontenorio/laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel

5161.1M3](/packages/robsontenorio-laravel-keycloak-guard)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[wp-graphql/wp-graphql-jwt-authentication

JWT Authentication for WPGraphQL

361118.4k1](/packages/wp-graphql-wp-graphql-jwt-authentication)

PHPackages © 2026

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