PHPackages                             wilbur/hyperf-soar - 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. [Database &amp; ORM](/categories/database)
4. /
5. wilbur/hyperf-soar

ActiveLibrary[Database &amp; ORM](/categories/database)

wilbur/hyperf-soar
==================

SQL optimizer and rewriter for Hyperf component.

3.1.0(2y ago)23884[1 issues](https://github.com/wilbur-yu/hyperf-soar/issues)MITPHPPHP &gt;=8.1

Since Oct 30Pushed 2y ago2 watchersCompare

[ Source](https://github.com/wilbur-yu/hyperf-soar)[ Packagist](https://packagist.org/packages/wilbur/hyperf-soar)[ RSS](/packages/wilbur-hyperf-soar/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (11)Versions (13)Used By (0)

hyperf-soar
===========

[](#hyperf-soar)

安装
--

[](#安装)

```
# hyperf 1.*
composer require wilbur/hyperf-soar:1.0 --dev

# hyperf 2.*
composer require wilbur/hyperf-soar --dev
```

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

[](#发布配置文件)

[详细配置](https://github.com/XiaoMi/soar/blob/master/doc/config.md)

```
php bin/hyperf.php vendor:publish wilbur/hyperf-soar

```

下载 soar
-------

[](#下载-soar)

```
# macOS
* wget https://github.com/XiaoMi/soar/releases/download/0.11.0/soar.darwin-amd64 -O vendor/bin/soar
# linux
* wget https://github.com/XiaoMi/soar/releases/download/0.11.0/soar.linux-amd64 -O vendor/bin/soar
# windows
* wget https://github.com/XiaoMi/soar/releases/download/0.11.0/soar.windows-amd64 -O vendor/bin/soar
# authorization
* chmod +x vendor/bin/soar
```

env 增加配置
--------

[](#env-增加配置)

```
SOAR_ENABLED=true
SOAR_TEST_DSN_DISABLE=false
SOAR_PATH=your_soar_path
SOAR_TEST_DSN_HOST=127.0.0.1
SOAR_TEST_DSN_PORT=3306
SOAR_TEST_DSN_DBNAME=yourdb
SOAR_TEST_DSN_USER=root
SOAR_TEST_DSN_PASSWORD=
SOAR_REPORT_TYPE=json
```

执行方式
----

[](#执行方式)

> 在 `hyperf start` 后,监听 `QueryExec` 事件, 在全局的响应中插入了监听到的 `sql` 列表对应的优化建议 目前只对response()-&gt;json()进行了插入

样例
--

[](#样例)

```
{
    "code": 200,
    "message": "success",
    "data": {
        "id": 0,
        "title": "谢谢参与",
        "type": "none",
        "value": "0"
    },
    "soar": [
        {
            "query": "select snapshot from u_awards where user_id = '41' and json_unquote(json_extract(snapshot, '$.\"type\"')) = 'cash'",
            "explain": [
                {
                    "Item": "FUN.001",
                    "Severity": "L2",
                    "Summary": "避免在 WHERE 条件中使用函数或其他运算符",
                    "Content": "虽然在 SQL 中使用函数可以简化很多复杂的查询，但使用了函数的查询无法利用表中已经建立的索引，该查询将会是全表扫描，性能较差。通常建议将列名写在比较运算符左侧，将查询过滤条件放在比较运算符右侧。也不建议在查询比较条件两侧书写多余的括号，这会对阅读产生比较大的困扰。",
                    "Case": "select id from t where substring(name,1,3)='abc'",
                    "Position": 0,
                    "Score": 90
                }
            ]
        },
        {
            "query": "select id, v, amount, balance, type, value, image, title from awards where balance > '0' and is_enabled = '1'",
            "explain": [
                {
                    "Item": "OK",
                    "Severity": "L0",
                    "Summary": "OK",
                    "Content": "OK",
                    "Case": "OK",
                    "Position": 0,
                    "Score": 100
                }
            ]
        },
        {
            "query": "select id, user_id, value from user_points where user_points.user_id in (41)",
            "explain": [
                {
                    "Item": "OK",
                    "Severity": "L0",
                    "Summary": "OK",
                    "Content": "OK",
                    "Case": "OK",
                    "Position": 0,
                    "Score": 100
                }
            ]
        },
        {
            "query": "update u_points set value = value - 20, u_points.updated_at = '2021-01-22 16:05:06' where id = '26'",
            "explain": [
                {
                    "Item": "OK",
                    "Severity": "L0",
                    "Summary": "OK",
                    "Content": "OK",
                    "Case": "OK",
                    "Position": 0,
                    "Score": 100
                }
            ]
        },
        {
            "query":"insert into u_awards (award_id, snapshot, client_ip, used_point, expired_at, extra, user_id, updated_at, created_at) values ('0', '{\"id\":0,\"v\":100,\"type\":\"none\",\"image\":\"\",\"value\":\"0\",\"title\":\"\谢\谢\参\与\"}', '127.0.0.1', '20', '2021-04-22 16:05:06', '[]', '41', '2021-01-22 16:05:06', '2021-01-22 16:05:06')",
            "explain": [
                {
                    "Item": "LIT.001",
                    "Severity": "L2",
                    "Summary": "用字符类型存储IP地址",
                    "Content": "字符串字面上看起来像IP地址，但不是 INET_ATON() 的参数，表示数据被存储为字符而不是整数。将IP地址存储为整数更为有效。",
                    "Case": "insert into tbl (IP,name) values('10.20.306.122','test')",
                    "Position": 207,
                    "Score": 90
                }
            ]
        }
    ]
}
```

感谢
--

[](#感谢)

- [soar](https://github.com/XiaoMi/soar)
- [soar-php](https://github.com/guanguans/soar-php)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 95.3% 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 ~139 days

Recently: every ~90 days

Total

12

Last Release

854d ago

Major Versions

1.0 → 2.0.02021-06-23

2.0.6 → 3.0.02023-01-15

PHP version history (4 changes)1.0PHP &gt;=7.2

2.0.0PHP &gt;=7.3

2.0.5PHP &gt;=8.0

3.1.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ba6eb722ff24398c7686e121aceabdc2265c883acb6685fa9abc9291f373e2b?d=identicon)[wilbur.yu](/maintainers/wilbur.yu)

---

Top Contributors

[![wilbur-yu](https://avatars.githubusercontent.com/u/7148309?v=4)](https://github.com/wilbur-yu "wilbur-yu (41 commits)")[![PandaLIU-1111](https://avatars.githubusercontent.com/u/26201936?v=4)](https://github.com/PandaLIU-1111 "PandaLIU-1111 (2 commits)")

---

Tags

phphyperfsoarwilburwilbur.yuphp-soarhyperf-soar

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/wilbur-hyperf-soar/health.svg)

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

###  Alternatives

[hyperf/odin

425.9k](/packages/hyperf-odin)[hyperf/database-pgsql

A pgsql handler for hyperf/database.

12282.0k13](/packages/hyperf-database-pgsql)[jonas-elias/hyperf-oracle

A oracle handler for hyperf/database.

102.0k](/packages/jonas-elias-hyperf-oracle)

PHPackages © 2026

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