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

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

papalapa/jwt
============

Library to Encode/Decode JWT (Json Web Tokens)

v1.0.0(6y ago)05MITPHPPHP &gt;=7.2CI failing

Since Mar 6Pushed 3mo ago1 watchersCompare

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

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

JWT (JSON Web Tokens) Encoder/Decoder
-------------------------------------

[](#jwt-json-web-tokens-encoderdecoder)

#### Installation

[](#installation)

`composer require papalapa/jwt`

#### PEM-key pare generate command

[](#pem-key-pare-generate-command)

`openssl req -x509 -nodes -newkey rsa:2048 -keyout jwt-key.pem -out jwt-cert.pem -days 365`

#### Example with Secret String

[](#example-with-secret-string)

```
use papalapa\jwt\Encoder;
use papalapa\jwt\Decoder;
use papalapa\jwt\KeyStorage;
use papalapa\jwt\PayloadOptions;use papalapa\jwt\Signers\HS256;

$secretString = '00000000000000000000000000000000';
$keyStorage = new KeyStorage($secretString);

$myAudience = 'my-site';
$encoder = new Encoder($myAudience, $keyStorage);
$token = $encoder->encode(new HS256(), ['username' => 'John Doe']); // eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6IkpvaG4gRG9lIn0.lv1XJ5-AKeciLPbEr0vV5XMgfdZMrUnK2t0GKkZapjU

$decoder = new Decoder('my-site', $keyStorage);
$payload = $decoder->decode($token); // ['username' => 'John Doe']

// with key pair
$cert = '/home/user/cert/cert.pem';
$key = '/home/user/cert/key.pem';
$keyStorage = new KeyStorage($secretString, $cert, $key);

// activation-time check (nbf attribute)
$decoder->setActivationCheck(true); // true by default
$payload = ['username' => 'John Doe', 'nbf' => '2030-01-01T00:00:00'];

// expiration-time check (exp attribute)
$decoder->setExpirationCheck(true); // true by default
$payload = ['username' => 'John Doe', 'exp' => '2030-01-01T00:00:00'];

// audience check (aud attribute)
$decoder->setAudienceCheck(true); // true by default
$payload = ['username' => 'John Doe', 'aud' => ['my-site', 'his-site', 'our-site']];

// using another config with attribute names in payload
$payloadOptions = new PayloadOptions([
    'aud' => 'audienceName',
    'exp' => 'expiredAt',
    'iss' => 'issuer'
]);
// using setters
$payloadOptions->setNbfArgument('activatedAt');
$payloadOptions->setAlgArgument('hasher');
$decoder = new Decoder($myAudience, $keyStorage, $payloadOptions);
```

#### Tests

[](#tests)

Runs tests using phpunit: `composer test`

#### Test coverage

[](#test-coverage)

Runs html-coverage tests using phpunit: `composer coverage`

#### Help

[](#help)

JWT online test: ****

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance54

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.9% 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

2264d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49ee8a513f2c7e607f87aedbba4f1281072b684083062c4e8a7943d580e16a3d?d=identicon)[papalapa](/maintainers/papalapa)

---

Top Contributors

[![papalapa](https://avatars.githubusercontent.com/u/6680467?v=4)](https://github.com/papalapa "papalapa (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

phpjwt

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[griffinledingham/php-apple-signin

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

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

The Hyperf JWT package.

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

SSO for Flarum

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

PHPackages © 2026

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