PHPackages                             axguowen/think-behaviorcaptcha - 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. axguowen/think-behaviorcaptcha

ActiveLibrary[Security](/categories/security)

axguowen/think-behaviorcaptcha
==============================

Simple Behavior Captcha for ThinkPHP

047PHP

Since Apr 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/axguowen/think-behaviorcaptcha)[ Packagist](https://packagist.org/packages/axguowen/think-behaviorcaptcha)[ RSS](/packages/axguowen-think-behaviorcaptcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

ThinkPHP 行为验证码
==============

[](#thinkphp-行为验证码)

一个简单的ThinkPHP 行为验证码扩展

主要功能：

支持多平台配置：目前支持极验(Geetest)、Vaptcha平台；

可扩展自定义平台驱动；

支持facade门面方式调用；

支持动态切换平台；

安装
--

[](#安装)

```
composer require axguowen/think-behaviorcaptcha

```

用法示例
----

[](#用法示例)

本扩展不能单独使用，依赖ThinkPHP6.0+

首先配置config目录下的behaviorcaptcha.php配置文件，然后可以按照下面的用法使用。

### 生成验证码数据

[](#生成验证码数据)

```
use think\facade\BehaviorCaptcha;

// 生成极验验证码数据
$createResult = BehaviorCaptcha::create();
// 成功
if(!is_null($createResult[0])){
    print_r($createResult[0]);
}
else{
    echo $createResult[1]->getMessage();
}
```

### 验证码校验

[](#验证码校验)

```
$verifyResult = BehaviorCaptcha::verify([
    'geetest_challenge' => 'xxxx',
    'geetest_validate' => 'xxxx',
    'geetest_seccode' => 'xxxx',
]);

// 成功
if(!is_null($verifyResult[0])){
    print_r($verifyResult[0]);
}
else{
    echo $verifyResult[1]->getMessage();
}
```

### 动态切换平台

[](#动态切换平台)

```
use think\facade\BehaviorCaptcha;

// 使用Vaptcha平台
$verifyResult = BehaviorCaptcha::platform('vaptcha')->verify([
    'vaptcha_server' => 'xxxx',
    'vaptcha_token' => 'xxxx',
]);

// 成功
if(!is_null($verifyResult[0])){
    print_r($verifyResult[0]);
}
else{
    echo $verifyResult[1]->getMessage();
}
```

配置说明
----

[](#配置说明)

```
// 验证码配置
return [
    // 默认验证平台
    'default' => 'geetest',
    // 验证平台配置
    'platforms' => [
        // 极验平台
        'geetest' => [
            // 驱动类型
            'type' => 'Geetest',
            // 极验验证ID
            'captcha_id' => '',
            // 极验私钥
            'private_key' => '',
            // 加密模式, 支持md5/sha256/hmac-sha256, 默认为md5
            'digestmod' => '',
            // 二次验证challenge字段名, 默认geetest_challenge
            'challenge_field' => '',
            // 二次验证validate字段名, 默认geetest_validate
            'validate_field' => '',
            // 二次验证seccode字段名, 默认geetest_seccode
            'seccode_field' => '',
        ],
        // vaptcha平台
        'vaptcha' => [
            // 驱动类型
            'type' => 'Vaptcha',
            // 验证单元的VID
            'vid' => '',
            // 验证单元的KEY
            'key' => '',
            // 验证场景
            'scene' => 0,
            // 二次验证server字段名 默认server
            'server_field' => '',
            // 二次验证token字段名 默认token
            'token_field' => '',
        ],
    ],
];
```

自定义平台驱动
-------

[](#自定义平台驱动)

如果需要扩展自定义验证平台驱动，需要继承\\think\\behaviorcaptcha\\PlatformInterface类, 并实现create方法和verify方法。

具体代码可以参考现有的平台驱动

扩展自定义驱动后，只需要在配置文件behaviorcaptcha.php中设置default的值为该驱动类名（包含命名空间）即可。

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

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/5bb2b3388238042a25cf42dc44e5ff84adc241510354abae9e91573556753205?d=identicon)[axguowen](/maintainers/axguowen)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/axguowen-think-behaviorcaptcha/health.svg)

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/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.7M113](/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)
