wiejakp/captcha

Captcha library for PHP applications.

Maintainers

Package info

github.com/wiejakp/captcha

Wiki

Documentation

pkg:composer/wiejakp/captcha

Transparency log

Statistics

Installs: 13 482

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.0 2026-07-30 16:59 UTC

This package is auto-updated.

Last update: 2026-07-30 17:01:31 UTC


README

Captcha library for PHP applications.

Requirements

  • PHP ^8.1
  • PHP Intl extension
  • Symfony HttpFoundation ^6.4
  • Symfony Security Core ^6.4

PCOV or Xdebug is required only when generating code coverage.

Installation

composer require wiejakp/captcha:^2.0

Usage

use wiejakp\captcha\CaptchaService;

$captcha = new CaptchaService();
$challenge = $captcha->createPositiveCaptchaChallenge();

echo $challenge->getChallenge();

if ($challenge->isEqual($submittedAnswer)) {
    // The answer is valid.
}

Challenges are stored in the configured Symfony session by default. Pass false to a creation method when the generated challenge should not be stored.

Tests

Run the suite under PHP 8.1:

composer test

With PCOV enabled, generate coverage using:

composer test:coverage