PHPackages                             szwsuny/qacompletion - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. szwsuny/qacompletion

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

szwsuny/qacompletion
====================

Query Auto Completion

1.1.3(7y ago)25MITPHPPHP &gt;=7.0.0

Since Feb 3Pushed 7y agoCompare

[ Source](https://github.com/szwsuny/QaCompletion)[ Packagist](https://packagist.org/packages/szwsuny/qacompletion)[ RSS](/packages/szwsuny-qacompletion/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

QaCompletion - 查询联想补全
=====================

[](#qacompletion---查询联想补全)

Query Auto Completion
---------------------

[](#query-auto-completion)

使用trie字典树进行前缀联想补全，可以用于输入框下拉提示，搜索下拉提示，根据添加词汇时候的sort值进行降序排序。

---

### 依赖

[](#依赖)

```
* PHP >= 7

```

---

### 使用方式

[](#使用方式)

```
* 可以参考test目录

```

引入项目

```
require __DIR__ . '/../vendor/autoload.php'; //注意调整所在目录位置

use SzwSuny\QA\Completion\QaCompletion;

```

声明对象

```
$qaCompletion = new QaCompletion();

```

添加词

```
$qaCompletion->adds($words); //$words是数组 格式为 [['词汇',2],['词汇1',2]] 数字为排序使用，越大越靠前
$qaCompletion->add($word,10); //$word是词汇  10 是排序值 你可以给任何数，越大值此词在结果中越靠前

```

更新排序值

```
$qaCompletion->upSort($word,10); //$word是词汇，10 是排序值，如果词汇不存在则失败。

```

清空所有联想词汇

```
$qaCompletion->clear(); //将会清空所有词，无法撤销，慎用。

```

补全联想

```
$qaCompletion->query('孙',10); //第一参数是要进行联想的字符串，第二个参数为返回联想到的条数，如果不填返回全部联想。

```

### 版本号说明

[](#版本号说明)

```
xx.xx.0 最后一位为0是正式版
xx.xx.1-99 这种属于测试版本

```

---

### 更新

[](#更新)

```
2019年02月3日 1.1.0
    发布正式版本

2019年02月06日 1.1.3
    吸收模式，能够跳过匹配不到的字符继续进行匹配，在Config中设置开启,1.1.3默认开启。

2019年02月14日 1.1.4
    修正remove反馈不正常

```

sunzhiwei 2019-2-3

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

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

2

Last Release

2654d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/27332034?v=4)[孙志伟](/maintainers/szwsuny)[@szwsuny](https://github.com/szwsuny)

---

Top Contributors

[![szwsuny](https://avatars.githubusercontent.com/u/27332034?v=4)](https://github.com/szwsuny "szwsuny (17 commits)")

---

Tags

completionphpqacphptrieqac

### Embed Badge

![Health badge](/badges/szwsuny-qacompletion/health.svg)

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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