PHPackages                             linjialiang/tp6-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. linjialiang/tp6-captcha

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

linjialiang/tp6-captcha
=======================

The Captcha class library for ThinkPHP 6.0, which relies on php\_Imagick

v6.0.12(6y ago)1342Apache-2.0PHP

Since Jan 9Pushed 6y ago1 watchersCompare

[ Source](https://github.com/linjialiang/tp6-captcha)[ Packagist](https://packagist.org/packages/linjialiang/tp6-captcha)[ RSS](/packages/linjialiang-tp6-captcha/feed)WikiDiscussions 6.0 Synced today

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

tp6-captcha
===========

[](#tp6-captcha)

thinkphp6 验证码类库

```
- 基于 ThinkPHP 6.0.x 编写
- 测试框架版本为 ThinkPHP 6.0.1
- 必备php扩展 Imagick

```

安装
--

[](#安装)

> composer require linjialiang/tp6-captcha

使用
--

[](#使用)

### 启用 Session

[](#启用-session)

ThinkPHP 6.0 下 `Session` 功能默认是没有开启的（API 通常不需要），如需开启可在 `全局中间件定义文件` 中加上下面的定义：

```
'think\middleware\SessionInit'

```

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

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

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

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

```

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

### 模板里输出验证码

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

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

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

```

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

```
{:captcha_img()}

```

或者

```

```

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

### 控制器里验证

[](#控制器里验证)

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

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

```

或者手动验证

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

```

字符说明
----

[](#字符说明)

默认字体，支持的字符有限，如需增加其它字符请重新载入字体：

目录描述assets/fonts@default常规字符集assets/fonts@zh中文字符集assets/fonts@math算术字符集assets/fonts@sourceFontForge 字体文件assets/bgs验证码背景图### 支持的字体类型

[](#支持的字体类型)

支持 3 种类型的字体： `ttf` 、 `ttc` 、 `otc`

### 字符集内容：

[](#字符集内容)

1. 中文字符集

    ```
    天地玄黄宇宙洪荒日月列张寒来暑往秋收冬闰余成岁律吕调阳云腾致雨结为金生丽水玉出昆冈剑号巨珠称夜光果珍李重姜海咸河淡羽翔龙师火帝鸟官人皇始制文字乃服衣裳推位让国有唐吊民伐罪周发汤坐朝问道垂拱平章爱育

    ```
2. 常规字符集

    ```
    2345678abcdefhjkmnpqrtuvwxyABCDEFHJKMNPQRTUVWXY

    ```
3. math 字符集

    ```
    空格字符+0123456789+-*/

    ```

参考来源
----

[](#参考来源)

tp6-captcha 灵感来自 [thinkphp 官方验证码类库](https://packagist.org/packages/topthink/think-captcha)，操作上与其基本一致！

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

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

Recently: every ~0 days

Total

13

Last Release

2240d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b1fde6e5f6dafa59f3996e99e259ac83a4780f16f5b959d392eea2e0bfa93e7?d=identicon)[linjialiang](/maintainers/linjialiang)

---

Top Contributors

[![linjialiang](https://avatars.githubusercontent.com/u/8848263?v=4)](https://github.com/linjialiang "linjialiang (28 commits)")

### Embed Badge

![Health badge](/badges/linjialiang-tp6-captcha/health.svg)

```
[![Health](https://phpackages.com/badges/linjialiang-tp6-captcha/health.svg)](https://phpackages.com/packages/linjialiang-tp6-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)
