PHPackages                             jdz/jdzcaptcha - 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. jdz/jdzcaptcha

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

jdz/jdzcaptcha
==============

JDZ icon Captcha package for PHP

2.0.4(1mo ago)014↓100%proprietaryPHPPHP &gt;=8.2

Since Mar 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/joffreydemetz/jdzcaptcha)[ Packagist](https://packagist.org/packages/jdz/jdzcaptcha)[ Docs](https://jdz.joffreydemetz.com/jdzcaptcha)[ RSS](/packages/jdz-jdzcaptcha/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (0)

JDZ Captcha
===========

[](#jdz-captcha)

A PHP icon-based CAPTCHA library. Instead of distorted text, users identify and select the image displayed the least number of times in a randomized grid of icons.

See [jdzcaptcha.joffreydemetz.com](https://jdzcaptcha.joffreydemetz.com) for more information on the PHP/JS implementation.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- GD extension (`ext-gd`)

Installation
------------

[](#installation)

```
composer require jdz/jdzcaptcha
```

Quick Start
-----------

[](#quick-start)

```
use JDZ\Captcha\Captcha;
use JDZ\Captcha\CaptchaConfig;

$config = new CaptchaConfig();
$captcha = new Captcha($config);
$captcha->init();

// Generate captcha data (returns base64-encoded JSON)
$data = $captcha->getCaptchaData('light', 1);

// Generate the image
$image = $captcha->getImage(1);
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);
```

### Handling User Selection (AJAX)

[](#handling-user-selection-ajax)

```
$result = $captcha->setSelectedAnswer([
    'i' => 1,     // captcha identifier
    'x' => 100,   // click x position
    'y' => 25,    // click y position
    'w' => 320,   // container width
]);
// Returns true if the correct icon was selected
```

### Form Validation

[](#form-validation)

```
use JDZ\Captcha\Exception\CaptchaValidationException;

try {
    $captcha->validate($_POST);
    // Captcha passed
} catch (CaptchaValidationException $e) {
    // Captcha failed
    echo $e->getMessage();
}
```

Session Adapters
----------------

[](#session-adapters)

The library ships with three session adapters:

**Native PHP session** (default):

```
$captcha = new Captcha($config); // uses NativeSession automatically
```

**Symfony**:

```
use JDZ\Captcha\Session\SymfonySession;

$adapter = new SymfonySession($symfonySession);
$captcha = new Captcha($config, $adapter);
```

**PSR-7/15** (Slim, Mezzio):

```
use JDZ\Captcha\Session\PsrSession;

$captcha = new Captcha($config, new PsrSession());
```

You can also implement `CaptchaSessionInterface` for any other framework.

Configuration
-------------

[](#configuration)

Pass options to `CaptchaConfig` or load from a YAML file:

```
$config = new CaptchaConfig();
$config->loadFromFile('/path/to/config.yaml');
```

### Available Options

[](#available-options)

OptionDefaultDescription`lang``'en'`Language code`token``true`Enable CSRF token validation`theme``'streamline'`Icon package`variant``'light'`Color variant (`light`, `dark`)`container.width``320`Container width in pixels`image.amount.min``5`Minimum icons in grid`image.amount.max``8`Maximum icons in grid`image.rotate``true`Randomly rotate icons`image.flip.horizontally``true`Random horizontal flip`image.flip.vertically``true`Random vertical flip`image.border``true`Draw divider lines`attempts.amount``3`Max attempts before timeout`attempts.timeout``60`Timeout duration in seconds`security.clickDelay``500`Min delay between clicks (ms)`security.hoverDetection``true`Detect hover behavior`security.invalidateTime``12000`Captcha expiration time (ms)Security Features
-----------------

[](#security-features)

- **CSRF token protection** - Configurable token-based protection
- **Honeypot field** - Hidden field to detect bots
- **Attempt limiting** - Configurable max attempts with timeout
- **Click delay** - Minimum delay between clicks to deter automation
- **Hover detection** - Detects human mouse behavior
- **Session expiration** - Captcha data expires after 30 minutes
- **Single-use images** - Each image can only be requested once

Frontend Integration
--------------------

[](#frontend-integration)

Retrieve the JavaScript configuration for the frontend:

```
$jsConfig = $captcha->getJsConfig(); // returns only non-default values
$token = $captcha->getToken()->make();
```

Testing
-------

[](#testing)

```
composer test
```

Acknowledgements
----------------

[](#acknowledgements)

This project was initially inspired by [IconCaptcha v3.1.1](https://github.com/fabianwennink/IconCaptcha-PHP).

License
-------

[](#license)

MIT - Copyright (c) 2018-present Joffrey Demetz. See [LICENSE](LICENSE) for details.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance89

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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 ~80 days

Recently: every ~1 days

Total

6

Last Release

57d ago

Major Versions

1.1.0 → 2.0.02026-04-06

PHP version history (2 changes)1.1.0PHP &gt;=8.1

2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e83e3701566e43438525ed14578487e732b849d152b5071aa1613a0dad96913?d=identicon)[jdz](/maintainers/jdz)

---

Top Contributors

[![joffreydemetz](https://avatars.githubusercontent.com/u/15113527?v=4)](https://github.com/joffreydemetz "joffreydemetz (18 commits)")

---

Tags

packagecaptchaservicesJDZ

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jdz-jdzcaptcha/health.svg)

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

###  Alternatives

[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k16.6M107](/packages/bensampo-laravel-enum)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[karser/karser-recaptcha3-bundle

Google ReCAPTCHA v3 for Symfony

1862.5M9](/packages/karser-karser-recaptcha3-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k44](/packages/friendsoftypo3-content-blocks)[laminas/laminas-captcha

Generate and validate CAPTCHAs using Figlets, images, ReCaptcha, and more

2419.2M49](/packages/laminas-laminas-captcha)

PHPackages © 2026

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