PHPackages                             oh86/laravel-captcha-tencentcloud - 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. oh86/laravel-captcha-tencentcloud

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

oh86/laravel-captcha-tencentcloud
=================================

tencentcloud captcha extend for oh86/laravel-captcha

v1.0.0(11mo ago)022MITPHPPHP ^7.4 || ^8.0

Since Jun 14Pushed 11mo agoCompare

[ Source](https://github.com/OneHundred86/laravel-captcha-tencentcloud)[ Packagist](https://packagist.org/packages/oh86/laravel-captcha-tencentcloud)[ RSS](/packages/oh86-laravel-captcha-tencentcloud/feed)WikiDiscussions main Synced 1mo ago

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

验证码-腾讯云行为验证码
============

[](#验证码-腾讯云行为验证码)

### 一、安装

[](#一安装)

```
composer require oh86/laravel-captcha-tencentcloud
```

### 二、配置 `config/captcha.php`

[](#二配置-configcaptchaphp)

```
return [
    'default' => env('CAPTCHA_DEFAULT_DRIVER', 'tencentCloud'),

    // ...

    // 腾讯云验证码配置
    'tencentCloud' => [
        'secret_id' => env('TENCENT_CLOUD_SECRET_ID'),
        'secret_key' => env('TENCENT_CLOUD_SECRET_KEY'),
        'region' => env('TENCENT_CLOUD_REGION', 'ap-guangzhou'),
        'captcha_app' => [
            'app_id' => (int) env('TENCENT_CLOUD_CAPTCHA_APP_ID'),
            'secret_key' => env('TENCENT_CLOUD_CAPTCHA_SECRET_KEY'),
        ],
    ],
];
```

### 二、使用

[](#二使用)

#### 1.验证验证码 demo1

[](#1验证验证码-demo1)

```
use Oh86\Captcha\Facades\Captcha;

// 验证
/** @var bool */
$result = Captcha::driver('tencentCloud')->verify(['ticket' => 'your_ticket_here', 'randStr' => 'your_rand_str_here', 'userIp' => 'your_user_ip_here']);
```

#### 2.验证验证码 demo2

[](#2验证验证码-demo2)

```
use App\Constants\ErrorCode;
use Illuminate\Http\Request;
use Oh86\Captcha\Facades\Captcha;
use Oh86\Http\Exceptions\ErrorCodeException;

trait CaptchaTrait
{
    /**
     * 校验验证码
     * @param \Illuminate\Http\Request $request
     * @throws \Oh86\Http\Exceptions\ErrorCodeException
     */
    protected function verifyCaptcha(Request $request)
    {
        $request->validate([
            'captcha_type' => 'nullable',
            'captcha' => 'required|array',
        ]);

        // 本地环境不校验
        if (config('app.env') == 'local') {
            return;
        }

        $captchaType = $request->captcha_type ?? Captcha::getDefaultDriver();

        if ($captchaType == 'image'){
            $request->validate([
                'captcha.type' => 'nullable',   // default,math,flat,mini,inverse
                'captcha.key' => 'required',
                'captcha.value' => 'required',
            ]);

            if (!Captcha::driver('image')->driver($request->captcha['type'] ?? null)->verify($request->captcha)) {
                throw new ErrorCodeException(ErrorCode::Error, '验证码错误');
            }
            return;
        } elseif ($captchaType == 'tencentCloud') {
            $request->validate([
                'captcha.ticket' => 'required',
                'captcha.randStr' => 'required',
            ]);

            $captcha = ['userIp' => $request->ip()] + $request->captcha;
        } else {
            throw new ErrorCodeException(ErrorCode::Error, '验证码类型不支持');
        }

        if (!Captcha::driver($request->captcha_type)->verify($captcha)) {
            throw new ErrorCodeException(ErrorCode::Error, '验证码错误');
        }
    }
}
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance52

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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

332d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c3f893211000acbd1a600e2159a778865e4f7e54661239721c9fb5c240d7626b?d=identicon)[oh86](/maintainers/oh86)

---

Top Contributors

[![OneHundred86](https://avatars.githubusercontent.com/u/22148561?v=4)](https://github.com/OneHundred86 "OneHundred86 (5 commits)")

### Embed Badge

![Health badge](/badges/oh86-laravel-captcha-tencentcloud/health.svg)

```
[![Health](https://phpackages.com/badges/oh86-laravel-captcha-tencentcloud/health.svg)](https://phpackages.com/packages/oh86-laravel-captcha-tencentcloud)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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