PHPackages                             sergeymitr/simple-php-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. sergeymitr/simple-php-jwt

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

sergeymitr/simple-php-jwt
=========================

Simple JWT Authentication using PHP

1.0.0(5y ago)011GPL-3.0-or-laterPHP

Since Mar 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sergeymitr/simple-php-jwt)[ Packagist](https://packagist.org/packages/sergeymitr/simple-php-jwt)[ RSS](/packages/sergeymitr-simple-php-jwt/feed)WikiDiscussions master Synced today

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

Simple PHP JWT
==============

[](#simple-php-jwt)

The library serves a single purpose: making JWT easier to work with.

Requirements
------------

[](#requirements)

- PHP 7.4 or higher.

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

[](#installation)

Run this command to install the library via Composer:

```
composer require sergeymitr/simple-php-jwt
```

Usage
-----

[](#usage)

### Creating and Encoding the Token

[](#creating-and-encoding-the-token)

Use `Token::create()` factory method to create a new token:

```
use Sergeymitr\SimpleJWT\Token;

$token = Token::create();
```

The token doesn't hold any data, so we'll need to fill that out:

```
$token->setIssuer('Sergeymitr\SimpleJWT')
    ->setSubject('Test Sample')
    ->setAudience('PHPUnit')
    ->setExpiration(new \DateTime('2020-02-02'))
    ->setNotBefore(new \DateTime('2020-01-01'))
    ->setIssuedAt(new DateTime('2020-01-15'))
    ->setID('sample-id');
```

All the data is optional, you only fill out what you need. These methods define the claim names described by [RFC 7519](https://tools.ietf.org/html/rfc7519).

You can also add custom values to your token:

```
$token->setCustomPayload('key', 'value');
```

To encode the token you will need use the `Token` object, and a secret string to encode it with.

```
use Sergeymitr\SimpleJWT\Encoder;

$encoded_token = Encoder::do($token, 'secret');
```

The `$encoded_token` will contain a string representation of the encoded and encrypted token.

### Decoding the Token

[](#decoding-the-token)

To decode the token you'll need the string representation of the token, and the secret string you encoded it with:

```
use Sergeymitr\SimpleJWT\Decoder;

$token = Decoder::do($encodedToken, 'secret');
```

The `Token` object provides a number of "getter" methods you can use to retrieve the values, which you can [review](https://github.com/sergeymitr/simple-php-jwt/blob/master/src/TokenInterface.php) in the interface `TokenInterface`.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

1879d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/50462b97435ce6205e83f55e458b461efe3f18a478e48754580d1eeff6715c7f?d=identicon)[sergeym](/maintainers/sergeym)

---

Top Contributors

[![sergeymitr](https://avatars.githubusercontent.com/u/1341249?v=4)](https://github.com/sergeymitr "sergeymitr (16 commits)")

---

Tags

jwtjwt-authenticationjwt-tokenjwt-tokensphp

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sergeymitr-simple-php-jwt/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M100](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

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

41721.2M117](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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