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

ActiveLibrary

digitickets/jwt
===============

Provides classes for creating and parsing JWTs.

1.0.1(1w ago)02MITPHPPHP &gt;=7.3CI passing

Since Mar 13Pushed 1w agoCompare

[ Source](https://github.com/digitickets/jwt)[ Packagist](https://packagist.org/packages/digitickets/jwt)[ RSS](/packages/digitickets-jwt/feed)WikiDiscussions main Synced today

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

digitickets/jwt
===============

[](#digiticketsjwt)

A small library for creating and parsing signed JWTs. Supports PHP 7.3 and above, and uses the `firebase/php-jwt` library under the hood.

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

[](#installation)

```
composer require digitickets/jwt
```

Usage
-----

[](#usage)

### 1. Create a config implementing `JwtConfigInterface`

[](#1-create-a-config-implementing-jwtconfiginterface)

Create a config class that provides the signing key and default token lifetime:

```
use DigiTickets\Jwt\Config\JwtConfigInterface;
use Firebase\JWT\Key;

class MyJwtConfig implements JwtConfigInterface
{
    public function getKey(): Key
    {
        return new Key($_ENV['MY_JWT_SECRET'], 'HS256');
    }

    public function getDefaultExpiresInMinutes(): int
    {
        return 1;
    }
}
```

### 2. Create a JWT

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

```
use DigiTickets\Jwt\JwtClaims;
use DigiTickets\Jwt\JwtData;
use DigiTickets\Jwt\JwtFactory;

$token = JwtFactory::createJwt(
    new MyJwtConfig(), // The config created in step 1.
    new JwtData([
        JwtClaims::AUDIENCE => 'my-service',
    ])
);

var_dump($token); // string(153) "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NzM0MzU5NjEsImV4cCI6MTc3MzQzNjAyMSwiYXVkIjoibXktc2VydmljZSJ9.7Y8Sr7RL9w453TuSpC-j5u8ZicbN6QSUtInu6xc2VpA"
```

Pass an explicit expiry in minutes as the third argument, or `0` for a non-expiring token:

```
// Expires in 30 days
$token = JwtFactory::createJwt($config, $jwtData, 1440 * 30);

// Never expires
$token = JwtFactory::createJwt($config, $jwtData, 0);
```

### 3. Parse and verify a token

[](#3-parse-and-verify-a-token)

```
use DigiTickets\Jwt\JwtParser;

$data = JwtParser::parseJwt($config, $token);

$data->get('aud');           // 'my-service'
$data->getIssuedAt();        // DateTime
$data->getExpirationTime();  // DateTime

print_r($data);
// Output:
// DigiTickets\Jwt\JwtData Object
// (
//    [data:DigiTickets\Jwt\JwtData:private] => Array
//        (
//            [iat] => 1773435961
//            [exp] => 1773436021
//            [aud] => my-service
//        )
//
// )
```

Throws a `Firebase\JWT` exception if the token is invalid, expired, or has a bad signature.

Testing
-------

[](#testing)

Because we are supporting an old version of PHP, it's advisable to run tests in a Docker container so we use the correct PHP version.

```
./shell.sh
# Inside the container:
composer install
composer test

```

###  Health Score

35

—

LowBetter than 81% of packages

Maintenance98

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

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

Total

2

Last Release

8d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/43ff80479dac1859112b124bcc63db5acc6d9cf39ea69fa5bf7aa4d5b7c5f0b1?d=identicon)[DigiTickets](/maintainers/DigiTickets)

---

Top Contributors

[![antriver](https://avatars.githubusercontent.com/u/251159?v=4)](https://github.com/antriver "antriver (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[google/apiclient

Client library for Google APIs

9.8k186.9M875](/packages/google-apiclient)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k93.5M574](/packages/laravel-socialite)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k83.0M475](/packages/laravel-passport)[google/auth

Google Auth Library for PHP

1.4k266.3M125](/packages/google-auth)[kreait/firebase-php

Firebase Admin SDK

2.4k38.3M65](/packages/kreait-firebase-php)

PHPackages © 2026

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