PHPackages                             petalbranch/icon-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. [Security](/categories/security)
4. /
5. petalbranch/icon-captcha

ActiveLibrary[Security](/categories/security)

petalbranch/icon-captcha
========================

IconCaptcha is a lightweight and secure PHP library for generating image-based click CAPTCHA challenges using open-source icon fonts (e.g., Font Awesome).

v1.3.1(4mo ago)218Apache-2.0PHP

Since Jan 18Pushed 3mo agoCompare

[ Source](https://github.com/PetalBranch/IconCaptcha)[ Packagist](https://packagist.org/packages/petalbranch/icon-captcha)[ RSS](/packages/petalbranch-icon-captcha/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (8)Used By (0)

IconCaptcha
===========

[](#iconcaptcha)

👉 中文 | [English](./README_EN.md)

这是一个轻量级、安全且易于集成的 PHP 图标点选验证码库。用户需要按照提示图标的顺序，在图片中依次点击对应的图标来完成验证。

✨ **特性**

- 安全性：验证逻辑完全在服务端执行，坐标位置带有容错校验。
- 自定义：支持自定义验证码尺寸、图标数量、干扰项数量。
- 扩展性：支持自定义字体文件（实现 IconSetInterface）和背景图片文件夹。
- 高性能：惰性加载资源，低内存占用

👀 **示意图**

> 以下图片为前端的验证码展示效果参考，具体需要自行实现。

[![](https://github.com/PetalBranch/resource/raw/main/iconcaptcha-diagram.webp?raw=true)](https://github.com/PetalBranch/resource/blob/main/iconcaptcha-diagram.webp?raw=true)

📦 安装
----

[](#-安装)

```
composer require petalbranch/icon-captcha
```

⚠️ 安全警告 (Security Warning)
--------------------------

[](#️-安全警告-security-warning)

`icon_captcha_generate()` 函数返回的数组中包含 `answer` 字段（正确坐标数据）。

绝对禁止 将 `answer` 字段直接返回给前端（浏览器/客户端）。 你 必须 将 `answer` 数据存储在服务端的 `Session`、`Redis` 或`数据库`中，验证时再取出比对。

快速开始
----

[](#快速开始)

1. 生成验证码

在你的控制器（Controller）中生成验证码数据：

```
