PHPackages                             srcker/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. srcker/captcha

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

srcker/captcha
==============

验证码类库，可用于API构成app、小程序、api等

v1.0.1(6y ago)16132Apache-2.0PHP

Since Aug 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/srcker/php-captcha)[ Packagist](https://packagist.org/packages/srcker/captcha)[ RSS](/packages/srcker-captcha/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

captcha
=======

[](#captcha)

验证码类库，可用于API构成app、小程序、api等

安装
--

[](#安装)

> composer require srcker/captcha

使用
--

[](#使用)

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

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

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

```
    use srcker/Captcha;

    $config  = [];
    $captcha = new Captcha($config);
    dump($captcha->entry());

    // 返回
    array(2) {
        ["code"] => string(4) "KK4Q"
        ["base64"] => string(2294) "data:image/png;base64,iVBOR..."
    }
```

配置可选参数
------

[](#配置可选参数)

```
    $config  = [
        // 验证码字符集合
        'codeSet'  => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY',
        // 使用中文验证码
        'useZh'    => false,
        // 中文验证码字符串
        'zhSet'    => '你好啊撒打算打算打',
        // 使用背景图片
        'useImgBg' => false,
        // 验证码字体大小(px)
        'fontSize' => 25,
        // 是否画混淆曲线
        'useCurve' => true,
        // 是否添加杂点
        'useNoise' => true,
        // 验证码图片高度
        'imageH'   => 0,
        // 验证码图片宽度
        'imageW'   => 0,
        // 验证码位数
        'length'   => 4,
        // 验证码字体，不设置随机获取
        'fontttf'  => '',
        // 背景颜色
        'bg'       => [243, 251, 254],
    ];
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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

2523d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/651508?v=4)[Sinda](/maintainers/Sinda)[@Sinda](https://github.com/Sinda)

---

Top Contributors

[![srcker](https://avatars.githubusercontent.com/u/6512197?v=4)](https://github.com/srcker "srcker (1 commits)")

### Embed Badge

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

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

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

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