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

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

lizhaoyang/captcha
==================

A captcha componet for hyperf .

v2.0(5y ago)9733MITPHPPHP &gt;=7.2CI failing

Since Jun 29Pushed 5y ago1 watchersCompare

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

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

**验证码组件**
---------

[](#验证码组件)

用于生产验证码，支持Hyperf框架，使用Composer安装,使用该组件需开启hyperf框架中的session组件

```
composer require lizhaoyang/captcha

```

**配置定义**
--------

[](#配置定义)

组件本身提供了默认配置，即使不做任何设置也可以直接生成验证码，需要对验证码进行自定义配置可以在config/autoload中添加captcha.php进行配置

```
return [
    'fontSize' => env('CAPTCHA_FONTSIZE', 25),
    'useCurve' => env('CAPTCHA_USECURVE', true),
    'useNoise' => env('CAPTCHA_USENOISE', true),
    'imageH'   => env('CAPTCHA_IMAGE_WIDTH', 0),
    'imageW'   => env('CAPTCHA_IMAGE_HEIGHT', 0),
    'length'   => env('CAPTCHA_LENGTH', 5),
    'bg'       => env('CAPTCHA_BG', [243, 251, 254]),
    'reset'    => env('CAPTCHA_RESET', true)
];

```

**直接使用**

```
/**
 * @Inject
 * @var ContainerInterface
 */
protected $container;

// 生产验证码
$captcha = new Captcha($this->container->get(ConfigInterface::class), $this->container->get(SessionInterface::class));
return $captcha->create();

// 验证
$captcha->check($code);

```

#### 动态设置

[](#动态设置)

```
$captcha->setFontSize(25);
$captcha->setImageWidth(100);
$captcha->setImageHeight(50);
$captcha->setLength(4);
$captcha->setUseCurve(true);
$captcha->setUseNoise(true);

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

Every ~0 days

Total

2

Last Release

2143d ago

Major Versions

v1.0 → v2.02020-06-29

### Community

Maintainers

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

---

Top Contributors

[![lzy309](https://avatars.githubusercontent.com/u/37437279?v=4)](https://github.com/lzy309 "lzy309 (13 commits)")

---

Tags

phpcaptchahyperf

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[tecactus/reniec-php

RENIEC package for PHP

118.4k](/packages/tecactus-reniec-php)[krowinski/one-click-captcha

Simple captcha that requires from user to only click a cut circle on image with several other circles. You can customize color of circles, background, width and height of image. Its very lightweight require no js just simple form in html and php gd extension.

131.7k](/packages/krowinski-one-click-captcha)

PHPackages © 2026

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