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

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

shoudian/jwt
============

A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.

09PHP

Since Apr 27Pushed 8y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

基于PhalApi2的JWT拓展
================

[](#基于phalapi2的jwt拓展)

描述
--

[](#描述)

JSON Web Token（JWT）是一个非常轻巧的规范。这个规范允许我们使用JWT在用户和服务器之间传递安全可靠的信息。

其他具体的信息请用户自行搜索.

附上:

官网地址:[http://www.phalapi.net/](http://www.phalapi.net/ "PhalApi官网")

项目GitHub地址:[https://github.com/shoudian/jwt.git](https://github.com/shoudian/jwt.git "项目Git地址")

安装PhalApi2-JWT
--------------

[](#安装phalapi2-jwt)

在项目的composer.json文件中，添加：

```
{
    "require": {
        "shoudian/jwt": "dev-master"
    }
}

```

配置好后，执行composer update更新操作即可。

配置文件
----

[](#配置文件)

我们需要在 **./config/app.php** 配置文件中追加以下配置：

```
    /**
     * 扩展类库 - JWT扩展
     */
	'jwt' => array(
		'iss' => '51sh.vip',
		'key' => 'secret'
	),

```

入门使用
----

[](#入门使用)

初始化PhalApi2-JWT,在config/di.php中加入如下代码

```

//jwt扩展
$di->jwt = new \Shoudian\JWT\Lite($di->config->get('app.jwt.key'));

```

常用基础操作(具体API可以查阅代码中src/Lite.php)

```
// 生成JWT
\PhalApi\DI()->jwt->encodeJwt($payload);

// 从header中获取AUTHORIZATION验证
\PhalApi\DI()->jwt->decodeJwt();

// 传入JWT验证
\PhalApi\DI()->jwt->decodeJwtByParam($token);

```

**如果大家有更好的建议可以私聊或加入到PhalApi大家庭中前来一同维护PhalApi****注:笔者能力有限有说的不对的地方希望大家能够指出,也希望多多交流!**

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9349b61de6028b7b2029e3eee3f279dd53c2d35b382b1d6a72cca32a593df1a6?d=identicon)[shoudian](/maintainers/shoudian)

---

Top Contributors

[![twodayw](https://avatars.githubusercontent.com/u/24267914?v=4)](https://github.com/twodayw "twodayw (1 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/shoudian-jwt/health.svg)](https://phpackages.com/packages/shoudian-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)
