PHPackages                             bjyyb/hyperf-accesstoken - 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. bjyyb/hyperf-accesstoken

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

bjyyb/hyperf-accesstoken
========================

hyperf-accesstoken身份认证组件

0141PHP

Since Nov 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/dinofei/hyperf-accesstoken)[ Packagist](https://packagist.org/packages/bjyyb/hyperf-accesstoken)[ RSS](/packages/bjyyb-hyperf-accesstoken/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

安装
--

[](#安装)

`composer require bjyyb/hyperf-accesstoken:dev-main`

发布配置文件
------

[](#发布配置文件)

`php bin/hyperf.php vendor:publish bjyyb/hyperf-accesstoken`

使用：
---

[](#使用)

### 生成 access\_token和refresh\_token

[](#生成-access_token和refresh_token)

```
$tokenService = $this->container->get(\Bjyyb\AccessToken\Contract\TokenInterface::class);
$payload = [
    "user_id" => 1,
    "name" => "xx",
];
$result = $tokenService->iss($payload);
/** 返回如下格式数据：*/
[
    "access_token" => "xxx",
    "refresh_token" => "xxx",
];
```

### 验证 access\_token

[](#验证-access_token)

```
$tokenService = $this->container->get(\Bjyyb\AccessToken\Contract\TokenInterface::class);
$token = "xx";
$payload = $tokenService->verify($token);
/** 返回如下格式数据：*/
[
    "user_id" => 1,
    "name" => "xx",
];
/** 如果验证失败抛出异常 */
```

### 使用refresh\_token 刷新 access\_token

[](#使用refresh_token-刷新-access_token)

```
$tokenService = $this->container->get(\Bjyyb\AccessToken\Contract\TokenInterface::class);
$refreshToken = "xx";
$result = $tokenService->refresh($refreshToken);
/** 返回新的令牌：*/
[
    "access_token" => "xxx",
    "refresh_token" => "xxx",
];
```

### 删除 access\_token和refresh\_token

[](#删除-access_token和refresh_token)

```
$tokenService = $this->container->get(\Bjyyb\AccessToken\Contract\TokenInterface::class);
$token = "xx";
$result = $tokenService->remove($token);
```

---

适配apiservice的token验证
--------------------

[](#适配apiservice的token验证)

### 安装jwt组件

[](#安装jwt组件)

`composer require bjyyb/hyperf-jwt:dev-main`

### 添加配置 config/jwt.php

[](#添加配置-configjwtphp)

```
[
'webtoken' => [
    // 签名算法
    'alg' => 'HS256',
    // 实体内容
    'payload' => [
    ],
    // 加密密钥
    'key' => 'abcd1234abcd',
    // 允许算法
    'allowed_algs' => ['HS256'],
],
];
```

### 解密token

[](#解密token)

```
$token = 'xxx';
$tokenService = $this->container->get(\Bjyyb\AccessToken\WebToken::class);
$data = $tokenService->verify($token);
var_dump($data);
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

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/c07efe51625decee52824c425b38c845c846b79e601a3fbd12a5ec5b39f4461c?d=identicon)[dinofei](/maintainers/dinofei)

### Embed Badge

![Health badge](/badges/bjyyb-hyperf-accesstoken/health.svg)

```
[![Health](https://phpackages.com/badges/bjyyb-hyperf-accesstoken/health.svg)](https://phpackages.com/packages/bjyyb-hyperf-accesstoken)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

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