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

ActiveSymfony-bundle

mulertech/captcha
=================

Symfony bundle providing a self-hosted image-based math captcha for bot protection

v1.0.0(1mo ago)00MITPHPPHP ^8.4CI passing

Since Mar 27Pushed 1mo agoCompare

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

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

MulerTech Captcha Bundle
========================

[](#mulertech-captcha-bundle)

---

[![Latest Version on Packagist](https://camo.githubusercontent.com/2ae6aecd397a8262214a6f0067d39a7ec75e0e5e5df30d5c0fcd821a4f8fd31d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d756c6572746563682f636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mulertech/captcha)[![GitHub Tests Action Status](https://camo.githubusercontent.com/78e9c1d1b03c0d0c444446486ac9c56bfbff175405b97fdb5e0dc760d6de65eb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d756c6572746563682f636170746368612f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mulertech/captcha/actions/workflows/tests.yml)[![GitHub PHPStan Action Status](https://camo.githubusercontent.com/61d74cfbf7356bf94149f7878c49c605132ee24325789b17afd6680b1a85f97b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d756c6572746563682f636170746368612f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/mulertech/captcha/actions/workflows/phpstan.yml)[![GitHub Security Action Status](https://camo.githubusercontent.com/51ed63665227b5f83a52c6dc7f655138c3e933726265fde9e39b7f8de8f4fa77/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d756c6572746563682f636170746368612f73656375726974792e796d6c3f6272616e63683d6d61696e266c6162656c3d7365637572697479267374796c653d666c61742d737175617265)](https://github.com/mulertech/captcha/actions/workflows/security.yml)[![Total Downloads](https://camo.githubusercontent.com/d873081b7c86bd3e6c5142cd2cf88449b6697712b04c5268055c95ce29dcc5b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d756c6572746563682f636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mulertech/captcha)[![Test Coverage](https://raw.githubusercontent.com/mulertech/captcha/badge/badge-coverage.svg)](https://packagist.org/packages/mulertech/captcha)

---

A self-hosted, image-based math captcha Symfony bundle. No external service required. Generates a random arithmetic operation rendered as a low-quality JPEG with noise, validated server-side via session. Protects contact and quote forms against bots without any third-party dependency.

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

[](#requirements)

- PHP 8.4+
- ext-gd
- Symfony 6.4, 7.x or 8.x

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

[](#installation)

```
composer require mulertech/captcha
```

Routes and form theme are **automatically registered** — no additional configuration required.

The bundle registers two endpoints:

RoutePathDescription`mulertech_captcha_image``GET /captcha/image?token=xxx`Returns the JPEG captcha image`mulertech_captcha_refresh``GET /captcha/refresh`Returns `{token, imageUrl}` JSON for JS refreshUsage
-----

[](#usage)

### 1. Add `CaptchaType` to your form

[](#1-add-captchatype-to-your-form)

```
use MulerTech\CaptchaBundle\Form\CaptchaType;

$builder->add('captcha', CaptchaType::class);
```

The field is automatically `mapped: false` and includes the `ValidCaptcha` constraint.

### 2. Render in your Twig template

[](#2-render-in-your-twig-template)

Render the field **before** the submit button. The widget displays the captcha image, a refresh button (JavaScript, no page reload), and the answer input:

```
{{ form_row(form.captcha) }}
Envoyer
{{ form_end(form) }}
```

### 3. Process the form in your controller

[](#3-process-the-form-in-your-controller)

No special handling required. `$form->isValid()` returns `false` if the captcha answer is wrong or expired, with a localized error message on the `captcha` field.

```
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
    // captcha passed — process the form
}
```

### Error messages

[](#error-messages)

SituationMessageWrong answer`Le code de vérification est incorrect.`Token expired / missing`Le code de vérification a expiré, veuillez recommencer.`CSP nonce support
-----------------

[](#csp-nonce-support)

The bundle's inline `` tag supports Content Security Policy nonces.

### Automatic (with `mulertech/csp-bundle`)

[](#automatic-with-mulertechcsp-bundle)

If [`mulertech/csp-bundle`](https://packagist.org/packages/mulertech/csp-bundle) is installed, the nonce is injected automatically — no additional configuration needed.

### Manual

[](#manual)

Pass the nonce explicitly via the `csp_nonce` option:

```
$builder->add('captcha', CaptchaType::class, [
    'csp_nonce' => $this->cspNonceGenerator->getNonce('main'),
]);
```

The nonce is added to the `` tag rendered by the form theme:

```
...
```

Security considerations
-----------------------

[](#security-considerations)

- **Token TTL**: captcha tokens expire after 10 minutes.
- **Session limit**: a maximum of 5 active tokens per session prevents session flooding.
- **Answer space**: math operations produce answers in the range 1–30. Apply **rate limiting** at the application level (e.g., Symfony's RateLimiter) to prevent brute-force attempts.

Testing
-------

[](#testing)

```
./vendor/bin/mtdocker test-ai
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/357d309912bbc5318d9877d1369987d2390c8e034b637e9f20671c28b09b5119?d=identicon)[mulertech](/maintainers/mulertech)

---

Top Contributors

[![mulertech](https://avatars.githubusercontent.com/u/57788787?v=4)](https://github.com/mulertech "mulertech (2 commits)")

---

Tags

symfonyspamcaptchaformbot-protection

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[a2lix/auto-form-bundle

Automate form building

873.8M11](/packages/a2lix-auto-form-bundle)

PHPackages © 2026

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