PHPackages                             lin-guifeng/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. [Security](/categories/security)
4. /
5. lin-guifeng/think-captcha

ActiveLibrary[Security](/categories/security)

lin-guifeng/think-captcha
=========================

captcha package for thinkphp6，前后端分离，使用redis

04PHP

Since May 18Pushed 4y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#think-captcha)

thinkphp6 前后端分离验证码类库

安装
--

[](#安装)

> composer require lin-guifeng/think-captcha @dev

注意
--

[](#注意)

本验证码只适用于前后端分离，并且需要提前开启redis

使用
--

[](#使用)

### 直接访问获取验证码

[](#直接访问获取验证码)

你的项目域名/captcha 如：

可在think-captcha/src/CaptchaController.php中修改适合自身项目的返回值

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

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

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

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

```

在控制器中可直接使用，返回验证码图片和对应的唯一键值

### 控制器里验证

[](#控制器里验证)

使用TP的内置验证功能即可（key与code需要使用'-'连接） 示例如下：

```
$data['captcha'] = input('key').'-'.input('code');
try {
    $this->validate($data,[
        'captcha|验证码'=>'require|captcha'
    ]);
} catch (ValidateException $e) {
    // 验证失败 输出错误信息
    dump($e->getError());
}

```

或者手动验证

```
if(!captcha_check($key, $code)){
 //验证失败
};

```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![lin-guifeng](https://avatars.githubusercontent.com/u/34935272?v=4)](https://github.com/lin-guifeng "lin-guifeng (4 commits)")

### Embed Badge

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

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

###  Alternatives

[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k18.7M142](/packages/mews-purifier)[paragonie/ecc

PHP Elliptic Curve Cryptography library

24820.0k37](/packages/paragonie-ecc)

PHPackages © 2026

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