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

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

phalapi/jwt
===========

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

22.8k↓66.7%2[2 issues](https://github.com/twodayw/phalapi2-jwt/issues)PHP

Since Apr 27Pushed 8y agoCompare

[ Source](https://github.com/twodayw/phalapi2-jwt)[ Packagist](https://packagist.org/packages/phalapi/jwt)[ RSS](/packages/phalapi-jwt/feed)WikiDiscussions master Synced 3d 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/twodayw/phalapi2-jwt.git](https://github.com/twodayw/phalapi2-jwt.git "项目Git地址")

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

[](#安装phalapi2-jwt)

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

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

```

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

配置文件
----

[](#配置文件)

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

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

```

入门使用
----

[](#入门使用)

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

```

//jwt扩展
$di->jwt = new \Phalapi\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

20

—

LowBetter than 14% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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/35d70b1236f8f67d96ba3da4ba88889faf2837ff8f7ab62acc54fe6cb4992c87?d=identicon)[dogstarhuang](/maintainers/dogstarhuang)

### Embed Badge

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

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