PHPackages                             verdient/token - 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. verdient/token

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

verdient/token
==============

Offline token generation and validation

0.1.0(4y ago)0509MITPHPPHP &gt;=7.0.0

Since Feb 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Verdient/token)[ Packagist](https://packagist.org/packages/verdient/token)[ Docs](https://github.com/Verdient/token)[ RSS](/packages/verdient-token/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (4)Used By (0)

令牌
==

[](#令牌)

用于生成及解析认证令牌

安装
--

[](#安装)

```
composer require verdient/token
```

生成秘钥
----

[](#生成秘钥)

```
use Verdient\token\Token;

/**
 * 秘钥
 */
$key = '***';

/**
 * 令牌有效期(s)
 * 默认为2592000，30天
 */
$duration = 2592000;

/**
 * 代价，代价值越大，生成的令牌越长，安全性越高，速度越慢
 * 默认为10
 */
$cost = 10;

$token = new Token([
	'key' => $key,
	'duration' => $duration,
	'cost' => $cost
]);

/**
 * 用于认证的关键信息
 * 可以是用户ID或其他用户唯一的值
 */
$identity = 1;

/*
 * $duration和$cost可以作为可选参数传入生成函数
 * 用于覆盖整全局的配置
 */
$tokenString = $token->generate($identity, $duration, $cost);
```

解析秘钥
----

[](#解析秘钥)

```
$identity = $token->parse($tokenString);
```

###  Health Score

23

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Every ~220 days

Total

3

Last Release

1790d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/606eaa4bc61b11fa19f25526a3084758b7086ceb8b11cdbcafd5df11871f2437?d=identicon)[Verdient。](/maintainers/Verdient%E3%80%82)

---

Top Contributors

[![Verdient](https://avatars.githubusercontent.com/u/22468867?v=4)](https://github.com/Verdient "Verdient (2 commits)")

---

Tags

validationAuthenticationtokenoffline

### Embed Badge

![Health badge](/badges/verdient-token/health.svg)

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

###  Alternatives

[kreait/firebase-tokens

A library to work with Firebase tokens

23939.3M9](/packages/kreait-firebase-tokens)[tuupola/branca

Authenticated and encrypted API tokens using modern crypto.

52301.5k1](/packages/tuupola-branca)[bizley/jwt

JWT integration for Yii 2

67409.2k2](/packages/bizley-jwt)[facile-it/php-openid-client

OpenID (OIDC) Client

41568.6k4](/packages/facile-it-php-openid-client)[dyorg/slim-token-authentication

Slim 3.0+ Token Authentication Middleware

78104.9k](/packages/dyorg-slim-token-authentication)[rinvex/authy

Rinvex Authy is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

35185.2k1](/packages/rinvex-authy)

PHPackages © 2026

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