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

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

xudongyss/jwt
=============

jwt

1.0.4(5y ago)017PHP

Since Dec 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/xudongyss/jwt)[ Packagist](https://packagist.org/packages/xudongyss/jwt)[ RSS](/packages/xudongyss-jwt/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

JSON WEB TOKEN
==============

[](#json-web-token)

\[TOC\]

安装
--

[](#安装)

```
composer require xudongyss/jwt

```

快速使用
----

[](#快速使用)

### 生成 TOKEN

[](#生成-token)

```
require_once 'vendor/autoload.php';

use xudongyss\jwt\Token;

/* 私钥 */
$private = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCDVzoilq8VoHeslQIB9a5kpabkWj+9lJ89w1Yk2rw2JQjafGME6mJAGCHN+2XQrijNgzboeNWogvYLZmfRiP64JQGXJabU8XmkbOOCFihNV48HeJZSqns+yVZPeWJ3NXzDDr0cFd/tzaqLm2gN+3oI4M8RbLFdsDgkiRnLUTSvy3RTTmBWkscBKy/TrAZHSPvErLSu5X2TP05kzMVTRaZaLwoj3hPO5aJrKqHADrkUO56dwvf0N+vyZGwWT/KNyYbL1fycGBdNlFwePAQ+s4PiZdJqInHnr0r8BbMCagIZqGTqD5iykFfwoz0bB3ZUzGBSx1YKs7OEDJmzhSifU+sZAgMBAAECggEANtTTkF0X+w9i5snObMMEa0A8zFhhA+RoFoDWFcy7hl8vswb6z7KKEfgBJN0vRE9w+VsuMR9BE3iY/2lhLjjjHj1UzKULYRrujZZn5Icb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FqUZvHbQCccNdaUhhwfEi2lIJoDikClXLB4=';
/* 公钥 */
$public = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg1c6IpavFaB3rJUCAfWuZKWm5Fo/vZSfPcNWJNq8NiUI2nxjBOpiQBghzftl0K4ozYM26HjVqIL2C2Zn0Yj+uCUBlyWm1PF5pGzjghYoTVePB3iWUqp7PslWT3lidzV8ww69HBXf7c2qi5toDft6CODPEWyxXbA4JIkZy1E0r8t0U05gVpLHASsv06wGR0j7xKy0ruV9kz9OZMzFU0WmWi8KI94TzuWiayqhwA65FDuencL39Dfr8mRsFk/yjcmGy9X8nBgXTZRcHjwEPrOD4mXSaiJx569K/AWzAmoCGahk6g+YspBX8KM9Gwd2VMxgUsdWCrOzhAyZs4Uon1PrGQIDAQAB';

/* 用户ID */
$uid = 100000001;
/* 扩展数据，可空 */
$extend = [];
$token = new Token($private, $public);
$token->create($uid, $extend);
```

### 校验

[](#校验)

```
/* Token */
$tokenString = '';
$token->validating($tokenString);
```

### 获取数据

[](#获取数据)

```
//jti
$token->getClaim('jti');
//uid
$token->getClaim('uid');
//extend
$token->getClaim('extend');
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~53 days

Total

5

Last Release

1868d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f89328b21f1a0ff093d7c8df84f784af3cdd9c81c016362a65eb98dac4634fe?d=identicon)[xudongyss](/maintainers/xudongyss)

---

Top Contributors

[![xudongyss](https://avatars.githubusercontent.com/u/44386082?v=4)](https://github.com/xudongyss "xudongyss (14 commits)")

### Embed Badge

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

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

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.7k151.3M327](/packages/league-oauth2-server)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.2k19.7k](/packages/prestashop-prestashop)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

84511.6M67](/packages/php-open-source-saver-jwt-auth)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

589701.7k2](/packages/scheb-2fa)[scheb/2fa-trusted-device

Extends scheb/2fa-bundle with trusted devices support

366.0M40](/packages/scheb-2fa-trusted-device)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M672](/packages/shopware-core)

PHPackages © 2026

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