PHPackages                             stru/stru-hyperf-oauth - 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. stru/stru-hyperf-oauth

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

stru/stru-hyperf-oauth
======================

Hyerf 下的 oauth2.0-Server 组件

v0.0.7(4y ago)110MITPHPPHP &gt;=7.3

Since Jan 25Pushed 4y ago1 watchersCompare

[ Source](https://github.com/stru001/stru-hyperf-oauth)[ Packagist](https://packagist.org/packages/stru/stru-hyperf-oauth)[ RSS](/packages/stru-stru-hyperf-oauth/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (14)Versions (8)Used By (0)

#### component-require

[](#component-require)

```
composer require stru/stru-hyperf-oauth

```

#### tips

[](#tips)

```
1. 该组件配合 "stru/stru-hyperf-ui" 组件使用可以免去自己写登录注册页码的麻烦
2. 该组件 依赖 "stru/stru-hyperf-auth" 组件中的部分功能，因此要使用该组件请务必安装
3. 该组件目前只实现了auto_code_grant验证方式，其他方式可自行参考官网实例进行补充

```

#### publish

[](#publish)

```
php bin/hyperf.php vendor:publish stru/stru-hyperf-ouath

```

#### migrate

[](#migrate)

```
php bin/hyperf.php migrate

```

#### create authCode Client

[](#create-authcode-client)

```
php bin/hyperf.php stru:client

该命令生成auth_code验证方式的客户端，需要手动输入name和回调地址

```

#### create rsa key

[](#create-rsa-key)

```
php bin/hyperf.php stru:keys

```

#### use

[](#use)

```
// 客户端----laravel做客户端代码示例

protected $url = 'http://192.168.10.1:8000/';           //客户端地址
protected $remoteUrl = 'http://192.168.10.10:9501/';    //oauth服务器地址
public function redirect(Request $request){
    $request->session()->put('state', $state = Str::random(40));

    $query = http_build_query([
        'client_id' => 1,
        'redirect_uri' => $this->url.'callback',
        'response_type' => 'code',
        'scope' => 'public',
        'state' => $state,
    ]);

    return redirect($this->remoteUrl.'oauth/authorize?'.$query);
}

public function callback(Request $request)
{
    $http = new Client();

    $response = $http->post($this->remoteUrl.'oauth/token', [
        'form_params' => [
            'grant_type' => 'authorization_code',
            'client_id' => 1,
            'client_secret' => 'QI7aUla1qVTVFqYRStqt5D56sR0s0L5HU0NS1YMG',
            'redirect_uri' => $this->url.'callback',
            'code' => $request->code,
        ],
    ]);

    return \json_decode((string) $response->getBody(), true);
}

```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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 ~0 days

Total

7

Last Release

1618d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19748622?v=4)[wenping\_gou](/maintainers/stru001)[@stru001](https://github.com/stru001)

---

Top Contributors

[![stru001](https://avatars.githubusercontent.com/u/19748622?v=4)](https://github.com/stru001 "stru001 (10 commits)")

---

Tags

phpoauthhyperf

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/stru-stru-hyperf-oauth/health.svg)

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

###  Alternatives

[hyperf/hyperf-skeleton

A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.

313190.9k](/packages/hyperf-hyperf-skeleton)[simplesamlphp/simplesamlphp-module-oidc

A SimpleSAMLphp module adding support for the OpenID Connect protocol

5018.2k1](/packages/simplesamlphp-simplesamlphp-module-oidc)[hyperf-ext/auth

The Hyperf Auth package.

2380.1k3](/packages/hyperf-ext-auth)

PHPackages © 2026

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