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

Abandoned → [leruge/jwt](/?search=leruge%2Fjwt)Library

leruge/tp6-jwt
==============

jwt thinkphp6 auth

1.0.2(5y ago)0319MITPHPPHP ^7.1.0

Since Nov 2Pushed 5y ago1 watchersCompare

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

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

tp6-jwt
=======

[](#tp6-jwt)

thinkphp6的jwt身份验证包。目前仅支持header传参验证。

安装
--

[](#安装)

`composer require leruge/tp6-jwt`

说明
--

[](#说明)

- 目前仅支持HS256算法加密。
- 准备支持如下三大类型加密方式：RSA,HASH,DSA。再各分256、384、512位。 默认是HS256，即hash 256位加密。
- 需要修改加密方式，请修改参数ALGO，参数选项：
    - HS256:hash256位
    - HS384:hash384位
    - HS512:hash512位
    - RS256:rsa256位
    - RS384:rsa384位
    - RS512:rsa512位
    - ES256:dsa256位
    - ES384:dsa384位
    - ES512:dsa512位

> 提示：RSA和DSA是非对称加密方式，除了修改ALGO参数外，需要配置public\_key和private\_key俩个参数。如果秘钥设置了密码，请配置好password参数。

使用方式
----

[](#使用方式)

1. builder方法，生成token字符串

```
$user = ['id' => 1];
$token = \leruge\facade\JWT::builder($user);
```

1. validate方法，如果通过返回true，失败抛出异常

```
\leruge\facade\JWT::validate();
```

1. auth方法，返回一个对象，可以数组式访问，token有效的时候可以获取正常的数据，无效的时候获取的都是空

```
$user = \leruge\facade\JWT::auth();
$uid = $user->id; // $user['id'];
```

1. 可以使用中间件JWT，如果成功就进行下一步，失败则返回 `['code' =>0, 'msg' => '失败信息']``\leruge\middleware\JWT::class`

传参方式
----

[](#传参方式)

- 将token加入header，如下`Authorization:bearer token`值

###  Health Score

24

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

1958d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2518593dfbc67ba8bc8e39bb30541fa3d8a7002f87240f2f8a6b99f26e4c9eb?d=identicon)[leruge@163.com](/maintainers/leruge@163.com)

---

Top Contributors

[![leruge](https://avatars.githubusercontent.com/u/33196309?v=4)](https://github.com/leruge "leruge (2 commits)")

### Embed Badge

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

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

###  Alternatives

[topthink/think

the new thinkphp framework

8.0k1.2M12](/packages/topthink-think)[topthink/think-queue

The ThinkPHP6 Queue Package

641664.0k68](/packages/topthink-think-queue)[topthink/think-swoole

Swoole extend for thinkphp

504170.5k18](/packages/topthink-think-swoole)[topthink/think-captcha

captcha package for thinkphp

132925.4k61](/packages/topthink-think-captcha)[topthink/think-worker

workerman extend for thinkphp

202224.6k9](/packages/topthink-think-worker)[topthink/think-migration

96452.1k117](/packages/topthink-think-migration)

PHPackages © 2026

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