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

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

switon/jwt
==========

HMAC JWT issue, validation, and optional kid-based key routing for Switon Framework

v1.0.0(1mo ago)021MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 2mo agoCompare

[ Source](https://github.com/switon-php/jwt)[ Packagist](https://packagist.org/packages/switon/jwt)[ Docs](https://github.com/switon-php/jwt)[ RSS](/packages/switon-jwt/feed)WikiDiscussions main Synced 3w ago

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

Switon JWT Package
==================

[](#switon-jwt-package)

[![JWT CI](https://camo.githubusercontent.com/fcb3e2145d82d9e8b418da3d34237e8a6a337b879e178ca08e5707b8db9155c7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f6a77742f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4a57542532304349)](https://github.com/switon-php/jwt/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's JWT contract for application services that want HMAC-signed tokens, `kid`-based key selection, and `exp`/`nbf`checks.

Highlights
----------

[](#highlights)

- **Token issuing and validation:** `JwtInterface` covers both sides of the JWT flow.
- **Per-token signing keys:** tokens can carry a key ID, and decode can use it to select the matching signing key.
- **Claim policy:** issued tokens get consistent `exp` and `nbf` claims.
- **Validation policy:** signatures and standard claim checks are enforced together.
- **Clear failure types:** invalid tokens surface as specific exceptions.

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

[](#installation)

```
composer require switon/jwt
```

Quick Start
-----------

[](#quick-start)

```
use Switon\Core\Attribute\Autowired;
use Switon\Jwt\JwtInterface;

class AuthService
{
    #[Autowired] protected JwtInterface $jwt;

    public function issueForTenant(int $userId, string $kid): string
    {
        return $this->jwt->encode(['user_id' => $userId], 3600, $kid);
    }

    public function authenticate(string $token, string $kid): array
    {
        return $this->jwt->decode($token, $kid);
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance87

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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

48d ago

### Community

Maintainers

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

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (5 commits)")

---

Tags

authenticationjwtswitontokensjwttokensAuthenticationswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k51.8M375](/packages/tymon-jwt-auth)[rbdwllr/reallysimplejwt

A really simple library to generate user authentication JSON Web Tokens.

2902.5M24](/packages/rbdwllr-reallysimplejwt)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

84611.1M64](/packages/php-open-source-saver-jwt-auth)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

41121.9M94](/packages/auth0-auth0-php)[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2745.3M3](/packages/auth0-login)[admad/cakephp-jwt-auth

CakePHP plugin for authenticating using JSON Web Tokens

163762.9k8](/packages/admad-cakephp-jwt-auth)

PHPackages © 2026

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