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

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

aiya-zhao/php-jwt
=================

这是一个php的jwt封装

v1.0.1(2y ago)15MITPHPPHP &gt;=7.2

Since Mar 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/aiya-zhao/php-jwt)[ Packagist](https://packagist.org/packages/aiya-zhao/php-jwt)[ RSS](/packages/aiya-zhao-php-jwt/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

要求
--

[](#要求)

- PHP &gt;= 7.4

安装
--

[](#安装)

```
composer require aiya-zhao/php-jwt

```

用法
--

[](#用法)

```
use AiyaZhao\Jwt\JWT;

// 前端接口token验证配置
$config_api = [
    'jwt_secret'     => 'abc',    // 秘钥
    'ttl'            => 60 * 2,   // 过期时间 分钟
    'refresh_ttl'    => 60 * 4,   // 刷新时间 分钟
    'alg'            => 'sha256'  // 签名算法
];

// 后台接口token验证配置
$config_admin = [
    'jwt_secret'     => 'bcd',
    'ttl'            => 60 * 24 * 2,
    'refresh_ttl'    => 60 * 24 * 4,
    'alg'            => 'sha256'
];

$token_api = JWT::config($config_api)->setSub(123)->getToken();  // 获取token
echo $token_api;  // 输出token
$head_arr = JWT::getHead();  // 获取头信息
$body_arr = JWT::getBody();  // 获取载荷信息
$jwt = JWT::parseToekn($token_api);   // 解析token信息
$head_arr = $jwt->getHead(); // 获取解析token的头信息
$check_token = JWT::checkToken($token_api); // 验证token有效期
$token_admin = "xxx.xxx.xxx"; // 后台token
$jwt_admin = JWT::config($config_admin)->parseToekn($token_admin);   // 解析后台接口token信息
$head_arr_admin = JWT::getHead();  // 获取头信息
$refresh_token = JWT::refreshToken();  // 刷新token
echo $refresh_token;  // 输出刷新后的token
$sub = JWT::getSub();  // 获取主题
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% 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 ~0 days

Total

2

Last Release

783d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.4

v1.0.1PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/84e8af25b2c2003a12e3f8d2c116f96a8085a8d43f25cfd427f0fe461878745e?d=identicon)[aiya-zhao](/maintainers/aiya-zhao)

---

Top Contributors

[![jianlibao333](https://avatars.githubusercontent.com/u/114286883?v=4)](https://github.com/jianlibao333 "jianlibao333 (2 commits)")[![aiya-zhao](https://avatars.githubusercontent.com/u/163961882?v=4)](https://github.com/aiya-zhao "aiya-zhao (1 commits)")

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/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.2M118](/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)
