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

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

lizus/php-captcha
=================

php captcha

010PHP

Since Nov 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/lizus/php-captcha)[ Packagist](https://packagist.org/packages/lizus/php-captcha)[ RSS](/packages/lizus-php-captcha/feed)WikiDiscussions main Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Captcha
===========

[](#php-captcha)

一个简化的验证码程序，客户端表单根据prefix的值生成验证码图片，用户填写验证码图片上的code，然后提交的时候将prefix和code同时提交到服务器，服务器验证数据库存储的prefix中的code与用户提交的code比较，不计大小写，相同的话就验证通过。

本程序使用`lizus/php-redis`，需要有`redis`支持，相关使用见 [lizus/php-redis](https://packagist.org/packages/lizus/php-redis#dev-master)。

使用composer安装
------------

[](#使用composer安装)

```
composer require lizus/php-captcha
```

生成验证码prefix
-----------

[](#生成验证码prefix)

```
$captcha = new \LizusCaptcha\Captcha();
echo $captcha->get_prefix();
```

生成验证码图片
-------

[](#生成验证码图片)

```
$captcha = new \LizusCaptcha\Captcha();
echo $captcha->create_captcha_image();
```

将code和prefix传值服务器后验证
--------------------

[](#将code和prefix传值服务器后验证)

```
$captcha = new \LizusCaptcha\Captcha();
echo $captcha->check_captcha($code);
```

WordPress中使用
------------

[](#wordpress中使用)

### 在functions.php中载入

[](#在functionsphp中载入)

```
\LizusCaptcha\load_captcha();
```

### 引用地址，通过ajax获取

[](#引用地址通过ajax获取)

- 验证码prefix获取： `admin_url('admin-ajax.php').'?action=get_captcha_prefix'`
- 验证码图片获取： `admin_url('admin-ajax.php').'?action=get_captcha_image&prefix={prefix}'`

示例见/test
--------

[](#示例见test)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

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/8a0aed58fd8cecb60124971238760d453634d22344572f2fc0153d76b935fab9?d=identicon)[lizus](/maintainers/lizus)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[ircmaxell/php-math-parser

A simple shunting-yard based math parser and executor for PHP

2916.7k](/packages/ircmaxell-php-math-parser)[bmcclure/cakephp-media-plugin

CakePHP Media Plugin

591.4k](/packages/bmcclure-cakephp-media-plugin)

PHPackages © 2026

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