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

ActiveLibrary

dysix/tp6-captcha
=================

tp6 前后端分离模式验证码机制

1.0(3y ago)114Apache-2.0PHP

Since May 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/dywin123/tp6-captcha)[ Packagist](https://packagist.org/packages/dysix/tp6-captcha)[ RSS](/packages/dysix-tp6-captcha/feed)WikiDiscussions main Synced 1mo ago

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

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

[](#tp6-captcha)

thinkphp6 验证码类库 ，适用于前后端分离模式，api接口验证码使用场景

安装
--

[](#安装)

> composer require dysix/tp6-captcha

使用
--

[](#使用)

### 注册路由

[](#注册路由)

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

```
//展示验证码图形
Route::get('captcha/:id', function(){
    return \Dysix\Tp6Captcha\facade\Captcha::create($id);
    //return \Dysix\Tp6Captcha\facade\Captcha::instance(['length'=>8])->create($id);//自定义更改配置项
});
//验证码接口
Route::get('captcha', function (){
        //验证码唯一标识
        $uniqid = uniqid((string)mt_rand(100000, 999999));
        $src = (string)\think\facade\Route::buildUrl('/captcha/' . $uniqid)->domain(true);
        $data = [
            'src'    => $src,
            'uniqid' => $uniqid,
        ];
        return json($data);
});
```

### 获取验证码

[](#获取验证码)

首先请求`验证码接口`获取信息，获取到的验证码数据如图示

```
{
	"src": "http://domain/captcha/720807640afff8834bd",
	"uniqid": "720807640afff8834bd"
}
```

前端图片使用返回的链接展示验证码图片

```

```

### 验证

[](#验证)

需将`验证码`与`uniqid`一起提交验证

```
	//登录
    public function index()
    {
    	$input = $this->request->post('', null, ['trim']);
    	if(!\Dysix\Tp6Captcha\facade\Captcha::check($input['captcha'], $input['uniqid'])){
            return json(['code' => 400, 'msg' => '验证码错误');
        }
    }
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

1098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/73b730d3a20c9dac8023c46026bea4454c90f98eb415ae825e07349c540e547e?d=identicon)[dysix](/maintainers/dysix)

---

Top Contributors

[![dywin123](https://avatars.githubusercontent.com/u/49011331?v=4)](https://github.com/dywin123 "dywin123 (38 commits)")

### Embed Badge

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

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

###  Alternatives

[topthink/think

the new thinkphp framework

8.0k1.2M13](/packages/topthink-think)[topthink/think-queue

The ThinkPHP6 Queue Package

640675.0k75](/packages/topthink-think-queue)[topthink/think-swoole

Swoole extend for thinkphp

477174.4k19](/packages/topthink-think-swoole)[topthink/think-captcha

captcha package for thinkphp

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

workerman extend for thinkphp

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

96460.8k121](/packages/topthink-think-migration)

PHPackages © 2026

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