PHPackages                             ganlvtech/think-kcaptcha - 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. ganlvtech/think-kcaptcha

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

ganlvtech/think-kcaptcha
========================

KCAPTCHA for thinkphp5

1.0.2(9y ago)1361Apache-2.0PHP

Since Dec 8Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ganlvtech/think-kcaptcha)[ Packagist](https://packagist.org/packages/ganlvtech/think-kcaptcha)[ RSS](/packages/ganlvtech-think-kcaptcha/feed)WikiDiscussions master Synced today

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

think-kcaptcha
==============

[](#think-kcaptcha)

thinkphp5 KCAPTCHA验证码类库

安装
--

[](#安装)

> composer require ganlvtech/think-kcaptcha

请确保在配置文件中开启了URL路由

\##使用

\###模板里输出验证码

```
{:captcha_img()}
```

或者

```

```

> 上面两种的最终效果是一样的

### 控制器里验证

[](#控制器里验证)

使用TP5的内置验证功能即可

```
$this->validate($data,[
    'captcha|验证码'=>'require|captcha'
]);
```

或者手动验证

```
if(!captcha_check($captcha)){
    //验证失败
};
```

### 验证码配置

[](#验证码配置)

在应用配置文件中可以添加下列配置参数

```
'captcha' => [
    // 验证码加密密钥
    'seKey' => 'ThinkPHP.CN',
    // 验证码过期时间（s）
    'expire' => 1800,
    // 验证成功后是否重置
    'reset' => true,
    // 验证码字符集合
    'codeSet' => '23456789abcdegikpqsvxyz',
    // 验证码图片宽度
    'imageW' => 160,
    // 验证码图片高度
    'imageH' => 80,
    // 验证码位数
    'length' => mt_rand(5, 7),
    // 【KCAPTCHA专用】KCAPTCHA字体图片所在目录
    'fontsdir' => 'fonts',
    // 【KCAPTCHA专用】KCAPTCHA字体图片中的字符表
    'alphabet' => "0123456789abcdefghijklmnopqrstuvwxyz",
    // 【KCAPTCHA专用】波动幅度
    'fluctuation_amplitude' => 8,
    // 【KCAPTCHA专用】白色杂点密度（0表示没有）
    'white_noise_density' => 1 / 6,
    // 【KCAPTCHA专用】黑色杂点密度（0表示没有）
    'black_noise_density' => 1 / 30,
    // 【KCAPTCHA专用】字符是否强制粘连
    'no_spaces' => true,
    // 【KCAPTCHA专用】下方是否显示credits（开启会在高度方向额外增加12px）（注：credit表示对原作者及其他有贡献者的谢启、及鸣谢者姓名）
    'show_credits' => true,
    // 【KCAPTCHA专用】credits内容（如果为空，则显示HTTP_HOST）
    'credits' => 'www.captcha.ru',
    // 【KCAPTCHA专用】验证码文字颜色
    'foreground_color' => [mt_rand(0, 80), mt_rand(0, 80), mt_rand(0, 80)],
    // 【KCAPTCHA专用】验证码背景颜色
    'background_color' => [mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255)],
    // 【KCAPTCHA专用】输出JPEG是压缩质量
    'jpeg_quality' => 75,
],
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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

3

Last Release

3490d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8651285?v=4)[Ganlv](/maintainers/ganlvtech)[@ganlvtech](https://github.com/ganlvtech)

---

Top Contributors

[![ganlvtech](https://avatars.githubusercontent.com/u/8651285?v=4)](https://github.com/ganlvtech "ganlvtech (3 commits)")

### Embed Badge

![Health badge](/badges/ganlvtech-think-kcaptcha/health.svg)

```
[![Health](https://phpackages.com/badges/ganlvtech-think-kcaptcha/health.svg)](https://phpackages.com/packages/ganlvtech-think-kcaptcha)
```

PHPackages © 2026

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