PHPackages                             yzh52521/think-captcha - 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. yzh52521/think-captcha

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

yzh52521/think-captcha
======================

captcha package for thinkphp

v1.0.9(3y ago)499Apache-2.0PHP

Since Oct 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/yzh52521/think-captcha)[ Packagist](https://packagist.org/packages/yzh52521/think-captcha)[ RSS](/packages/yzh52521-think-captcha/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (1)Versions (10)Used By (0)

think-captcha
=============

[](#think-captcha)

thinkphp6 验证码类库 支持前后端分离，api接口调用

安装
--

[](#安装)

> composer require yzh52521/think-captcha

使用
--

[](#使用)

### 在控制器中输出验证码

[](#在控制器中输出验证码)

在控制器的操作方法中使用

```
public function captcha($id = '')
{
	return captcha($id);
}

```

然后注册对应的路由来输出验证码

### 模板里输出验证码

[](#模板里输出验证码)

首先要在你应用的路由定义文件中，注册一个验证码路由规则。

```
\think\facade\Route::get('captcha/[:id]', "\\yzh52521\\captcha\\CaptchaController@index");

```

然后就可以在模板文件中使用

```
{:captcha_img()}

```

或者

```

```

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

### 控制器里验证

[](#控制器里验证)

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

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

```

或者手动验证

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

```

api使用
-----

[](#api使用)

```
public function captcha($id = '')
{
   return yzh52521\captcha\facade\Captcha($id,true);
}

```

### api验证

[](#api验证)

```
if (!yzh52521\captcha\facade\Captcha::checkApi($data['verify'], $data['key'])) {
   throw new ValidateException('验证码错误');
}

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Recently: every ~12 days

Total

9

Last Release

1108d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/052aa4acd90ad5d672ae5abe8d27d1f576f9c07e1967e2f6bced03b84079310f?d=identicon)[yuanzhihai](/maintainers/yuanzhihai)

---

Top Contributors

[![yuanzhihai](https://avatars.githubusercontent.com/u/15060466?v=4)](https://github.com/yuanzhihai "yuanzhihai (27 commits)")

### Embed Badge

![Health badge](/badges/yzh52521-think-captcha/health.svg)

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

###  Alternatives

[topthink/think-captcha

captcha package for thinkphp

132934.4k67](/packages/topthink-think-captcha)[topthink/think-worker

workerman extend for thinkphp

202227.2k9](/packages/topthink-think-worker)[yunwuxin/think-cron

计划任务

17416.2k](/packages/yunwuxin-think-cron)[zzstudio/think-addons

The ThinkPHP6 Addons Package

1518.6k](/packages/zzstudio-think-addons)[topthink/think-annotation

Annotation For ThinkPHP

4831.5k8](/packages/topthink-think-annotation)[liliuwei/thinkphp-jump

适用于thinkphp6.0的跳转扩展

2874.4k1](/packages/liliuwei-thinkphp-jump)

PHPackages © 2026

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