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 3y 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 4w ago

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

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

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://www.gravatar.com/avatar/260eab8f8457cc88c6c666f28e9265742c9b4ec33463c6e2a1e89ed62b216705?d=identicon)[linguifeng](/maintainers/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

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M212](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

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

2.0k16.7M112](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

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