PHPackages                             ew80/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. ew80/think-captcha

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

ew80/think-captcha
==================

TP5-6前后端分离验证码

1.0.1(3y ago)017Apache-2.0PHP

Since Mar 6Pushed 3y ago1 watchersCompare

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

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

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

[](#think-captcha)

基于TP5.1，其它版本并不一定兼容。 前后端完全分离的图形验证码

功能概述： 1、基于前后端分离的生成、效验图片验证码 2、生成自定义验证码 3、使用cache缓存，非session 配置与TP官方的通用

安装
--

[](#安装)

> composer require ew80/think-captcha

前后端分离中使用
--------

[](#前后端分离中使用)

###### 配置缓存

[](#配置缓存)

打开TP框架中的/config/cache.php配置好缓存设置

###### 生成图片验证码

[](#生成图片验证码)

```

use ew80\captcha\facade\CaptchaApi;

$data = CaptchaApi::create();

其中$data 返回为：
{
    "base64": "base64格式",
    "key": "验证码的KEY",
    "md5": "e10adc3949ba59abbe56e057f20f883e",
	"code": "9515"
}

base64: 图片base64地址
key: 前端提交验证
md5: 验证码端md5值
code: 验证码值

```

###### 验证图片验证码

[](#验证图片验证码)

```

if ( ! CaptchaApi::check($code,$key)) {
	//验证码错误
}

前端表单提交：code、key

```

###### 生成自定义验证码

[](#生成自定义验证码)

```

use ew80\captcha\facade\CaptchaApi;

$data = CaptchaApi::createCode($userID);//比如用户ID、账号等，自定义

其中$data 返回为：
{
    "key": "123456",
	"code": "9541"
}

key: 原样返回，用于前端提交验证
code: 验证码值，用于自定义验证，比如：邮件、短信等

```

###### 验证自定义验证码

[](#验证自定义验证码)

```

if ( ! CaptchaApi::checkCode($code,$key)) {
	//验证码错误
}

前端表单提交：code、key

```

来源
--

[](#来源)

```
基于think-captcha进行扩展，可继续使用原版 captcha.php 验证码配置文件

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

1215d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/432dbb7b67de6a46bacaf94806b0ac5ceea5a425a8fcf6f4782453c5c38f9081?d=identicon)[80network](/maintainers/80network)

---

Top Contributors

[![80network](https://avatars.githubusercontent.com/u/78529547?v=4)](https://github.com/80network "80network (8 commits)")

### Embed Badge

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

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

###  Alternatives

[edward1108/edward-captcha

ThinkPHP6验证码(图片、短信)支持api友好化

158.0k](/packages/edward1108-edward-captcha)

PHPackages © 2026

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