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

ActiveLibrary

gsx/jwt-php
===========

PHP生成、验证 JWT

25PHP

Since Jul 17Pushed 1y agoCompare

[ Source](https://github.com/EricGSX/jwt)[ Packagist](https://packagist.org/packages/gsx/jwt-php)[ RSS](/packages/gsx-jwt-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

JWT
===

[](#jwt)

JWT（JSON Web Token）是一种开放标准（RFC 7519），定义了一种紧凑且自包含的方式，用于在各方之间安全地传输信息作为 JSON 对象。JWT 可以在用户和服务之间传递声明，这些声明可以被验证和信任。JWT 可以被用于身份验证（authentication）和信息交换（information exchange）。

一个 JWT 由三部分组成，它们通过点号 . 分隔开来：

- Header（头部）：包含了关于生成的 JWT 的元数据，比如令牌的类型（即 JWT）、所使用的加密算法等。
- Payload（载荷）：包含了声明（claims），是关于实体（通常是用户）和其他数据的信息。
- Signature（签名）：使用指定的算法对头部、载荷进行签名，确保 JWT 没有被篡改。

### 使用说明

[](#使用说明)

#### 生成JWT

[](#生成jwt)

```
 use Jwt\GuoJwt;
 $jwt=new GuoJwt($key);  #key 可动态设置，有默认值
 $payload=array('sub'=>'1234567890','name'=>'Guo','iat'=>1516239022);
 $token=$jwt->getToken($payload);

```

#### 验证JWT合法性

[](#验证jwt合法性)

```
$jwt2=new GuoJwt($key);
$getPayload=$jwt2->verifyToken($token);
var_dump($getPayload);

```

这里需要引入一下，否则会报错class不存在

```
        "files": [
            "vendor/gsx/jwt-php/autoload.php"
        ]

```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![EricGSX](https://avatars.githubusercontent.com/u/24319361?v=4)](https://github.com/EricGSX "EricGSX (13 commits)")

### Embed Badge

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

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

PHPackages © 2026

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