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

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

xinmiti/captcha
===============

A versatile captcha library supporting multiple frameworks and storage drivers

v1.0.1(1y ago)02MITPHPPHP &gt;=7.4

Since Mar 3Pushed 1y ago1 watchersCompare

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

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

Xinmiti Captcha
===============

[](#xinmiti-captcha)

一个功能强大的验证码库，支持多种验证码类型和存储驱动。

特性
--

[](#特性)

- 支持多种验证码类型：
    - 字母数字验证码
    - 中文验证码
    - 滑块验证码
    - 旋转图片验证码
- 支持多种存储驱动：
    - File
    - Redis
    - Memcache
    - Database
    - Cookie
- 支持 ThinkPHP 6.0/8.0+
- 高度可配置
- 简单易用

安装
--

[](#安装)

```
composer require xinmiti/captcha
```

配置
--

[](#配置)

### ThinkPHP 配置

[](#thinkphp-配置)

配置文件会自动发布到 `config/captcha.php`，你可以根据需要修改配置。

```
return [
    // 验证码存储驱动
    'driver' => 'file',

    // 更多配置...
];
```

使用示例
----

[](#使用示例)

### 基本使用

[](#基本使用)

```
use Xinmiti\Captcha\Captcha;

$captcha = new Captcha();

// 创建字母数字验证码
$result = $captcha->create();
// 返回: ['key' => '...', 'image' => 'data:image/png;base64,...']

// 创建中文验证码
$result = $captcha->createChinese();
// 返回: ['key' => '...', 'image' => 'data:image/png;base64,...']

// 创建滑块验证码
$result = $captcha->createSlide();
// 返回: ['key' => '...', 'image' => 'data:image/png;base64,...', 'block' => 'data:image/png;base64,...']

// 创建旋转验证码
$result = $captcha->createRotate();
// 返回: ['key' => '...', 'image' => 'data:image/png;base64,...']

// 验证
$isValid = $captcha->verify($key, $code);
```

### 在 ThinkPHP 中使用

[](#在-thinkphp-中使用)

```
use think\facade\Captcha;

// 创建验证码
$result = Captcha::create();

// 验证
$isValid = Captcha::verify($key, $code);
```

自定义配置
-----

[](#自定义配置)

你可以在实例化时传入自定义配置：

```
$config = [
    'driver' => 'redis',
    'stores' => [
        'redis' => [
            'host' => '127.0.0.1',
            'port' => 6379,
            'password' => 'your-password',
            'database' => 0
        ]
    ],
    'config' => [
        'length' => 6,
        'expire' => 600,
        // 更多配置...
    ]
];

$captcha = new Captcha($config);
```

许可证
---

[](#许可证)

MIT

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance44

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

440d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6c9fcd3c17b09243dd9ede77ab9ba673668cd08170e1c3842779d76773e9dd79?d=identicon)[xinmiti](/maintainers/xinmiti)

---

Top Contributors

[![xinmiti](https://avatars.githubusercontent.com/u/40022543?v=4)](https://github.com/xinmiti "xinmiti (7 commits)")

---

Tags

phpcaptcha

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[yangbx/captcha-lumen

captcha for lumen

123.8k](/packages/yangbx-captcha-lumen)

PHPackages © 2026

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