PHPackages                             chencongbao/ajcaptcha - 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. chencongbao/ajcaptcha

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

chencongbao/ajcaptcha
=====================

This is a behavior verification code PHP back-end implementation package

v1.0.0(8mo ago)036GPL-3.0-onlyPHPPHP &gt;=7.1

Since Aug 19Pushed 8mo agoCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

AJ-Captcha · php
----------------

[](#aj-captcha--php)

#### 介绍

[](#介绍)

这个类库使用 PHP实现了行为验证码。基于gd扩展生成滑动验证码和文字验证码。允许 phper定制验证码规则，并且不再使用 curl来请求第三方验证。

Java实现：

PHP实现：

##### 官方预览效果

[](#官方预览效果)

[![block](https://camo.githubusercontent.com/159a0a63c40769962c27f86f1387234ed9e047dd8d0e6b2a80d619c9f7854828/68747470733a2f2f67697465652e636f6d2f616e6a692d706c75732f636170746368612f7261772f6d61737465722f696d616765732f2545362542422539312545352538412541382545362538422542432545352539422542452e676966)](https://camo.githubusercontent.com/159a0a63c40769962c27f86f1387234ed9e047dd8d0e6b2a80d619c9f7854828/68747470733a2f2f67697465652e636f6d2f616e6a692d706c75732f636170746368612f7261772f6d61737465722f696d616765732f2545362542422539312545352538412541382545362538422542432545352539422542452e676966) [![click](https://camo.githubusercontent.com/a583f5e718d5dda07e56cd43e5b228d39962fdb7dae7383822b8d2cb468677af/68747470733a2f2f67697465652e636f6d2f616e6a692d706c75732f636170746368612f7261772f6d61737465722f696d616765732f2545372538322542392545392538302538392545362539362538372545352541442539372e676966)](https://camo.githubusercontent.com/a583f5e718d5dda07e56cd43e5b228d39962fdb7dae7383822b8d2cb468677af/68747470733a2f2f67697465652e636f6d2f616e6a692d706c75732f636170746368612f7261772f6d61737465722f696d616765732f2545372538322542392545392538302538392545362539362538372545352541442539372e676966)

#### 注意事项

[](#注意事项)

- 你需要打开 gd、 openssl扩展
- PHP版本至少需要7.1
- 此软件包自带缓存，如有需要请自行更换
- anji-plus/captcha前端默认请求头是 application/json 需替换为 application/x-www-form-urlencode
- 滑动验证图响应时间慢？

    > 性能慢的主要原因是受php GD库的imagecolorat函数与imagesetpixel函数性能的影响

    1. 您可以尝试将修改内存`ini_set('memory_limit', '256M')`
    2. 将本包升级到1.1.0以上的版本，开启像素缓存`block_puzzle.is_cache_pixel = true`, 若还是性能还是慢，则将干扰图片关闭`block_puzzle.is_interfere => false`

#### 如何使用

[](#如何使用)

test 目录下示例了三种使用方式，phper可以参考使用。[查看demo](./demo.md)

> 本软件包需要配合composer一起使用

1. 非框架使用的场景，直接使用git下载这个软件包。然后执行composer命令`composer install`安装本软件包依赖，接着手动引入对应的 service层文件即可（同test目录里的原生引用方式）。
2. 基于框架使用的场景,输入安装命令`composer require fastknife/ajcaptcha`（稳定版） 或者`composer require fastknife/ajcaptcha dev-master`（最新版） ，建议使用composer阿里源（`https://mirrors.aliyun.com/composer`）

    - 支持各种前沿框架（ThinkPHP, YII, Laravel, Hyperf，IMI,Swoft,EasySwoole）
    - 本软件包内，未使用单例、注册树（容器）模式，不含任何全局变量，基于swoole开发的同学不用担心内存泄露。

#### 项目结构

[](#项目结构)

> 本软件包基于整洁架构理念，设计了下文的目录结构。Domain(领域层)作为内层同心圆承担所有业务逻辑功能，Service（服务层）并向最外层Controller（需自行实现）提供粗颗粒度服务。
> 区别于DDD(领域驱动设计),本软件包的领域层不含Entity(实体)，以Logic（逻辑层）实现单元逻辑，为了方便管理作者将逻辑层的数据处理与图形处理分隔，以达到整洁效果。

```
AJ-Captcha for php
│
├─resources 资源
│	│
│	├─defaultImages 图片资源
│	│
│	└─fonts 字体
│
├─src 源码
│	│
│	├─Domian 领域层
│	│
│	├─Exception 异常
│	│
│	├─Service 服务层
│	│
│	├─ Utils工具类
│	│
│	└─ config.php 配置参考
└─test 测试实例
	│
	├─thinkphp thinkphp框架测试示例
	│
	├─laravel laravel框架测试示例
	│
	└─*.php 原生测试文件 配置文件

```

#### [更新日志](./changelog.md)

[](#更新日志)

若此软件对您有所帮助，您可以点右上角 💘Star💘支持

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance59

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity30

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

Unknown

Total

1

Last Release

264d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/chencongbao-ajcaptcha/health.svg)

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

###  Alternatives

[webmozart/assert

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

7.6k894.0M1.2k](/packages/webmozart-assert)[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)
