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

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

think/jwt
=========

1.0.0(7y ago)2495MITPHPPHP &gt;=5.6

Since Jun 13Pushed 7y agoCompare

[ Source](https://github.com/chichengyu/think-thinkphp-jwt)[ Packagist](https://packagist.org/packages/think/jwt)[ RSS](/packages/think-jwt/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

think-jwt
=========

[](#think-jwt)

一个php的jwt封装包，方便直接使用，我这里安装是的 `"lcobucci/jwt": "^3.3"`

基本使用
====

[](#基本使用)

使用之前必须先安装 `jwt`，使用 composer 安装

```
composer require lcobucci/jwt

```

然后再安装本包

```
composer require think/jwt

```

安装之后，即可在需要使用的类中use引入

```
use think\Jwt;

```

然后调用方法：genToken获取 token

```
$token = Jwt::getInstance()
            ->setIss('cyb.cn.admin') // 签发者
            ->setAud('cyb.cn') // 接收者
            ->setUid(1) // uid
            ->setExpire(7200) // 过期时间
            ->setKey('key') // 密钥
            ->encode()
            ->genToken();

```

验证 token

```
try{
	$a = Jwt::getInstance()
	            ->setIss('cyb.cn.admin')// 签发者
	            ->setAud('cyb.cn') // 接收者
	            ->setKey('key') // 密钥
	            ->setToken($token) // token
	            ->validate()
	$$b = Jwt::getInstance()
	            ->setIss('cyb.cn.admin')// 签发者
	            ->setAud('cyb.cn') // 接收者
	            ->setKey('key') // 密钥
	            ->setToken($token) // token
	            ->validate()
	if($a && $b){
		return true;
	}
	return false
}catch (\Exception $e){
	return false;
}

```

在thinkphp5里基本使用就是以上如此了，封装这个只为方便使用

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2576d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31581269?v=4)[chichengyu](/maintainers/chichengyu)[@chichengyu](https://github.com/chichengyu)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.3M17](/packages/kartik-v-yii2-password)[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

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