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

ActiveSymfony-bundle[Security](/categories/security)

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

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

v1.0.0(3mo ago)0112MITPHPPHP ^8.4CI passing

Since Mar 27Pushed 3w ago1 watchersCompare

[ Source](https://github.com/mulertech/captcha)[ Packagist](https://packagist.org/packages/mulertech/captcha)[ Docs](https://github.com/mulertech/captcha)[ RSS](/packages/mulertech-captcha/feed)WikiDiscussions main Synced 3w 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)[![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
```

The form theme is **automatically registered** — no additional configuration required.

### Routes

[](#routes)

Import the bundle routes in your application:

```
# config/routes/mulertech_captcha.yaml
mulertech_captcha:
    resource: "@MulerTechCaptchaBundle/config/routes.yaml"
```

The bundle provides 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

42

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community7

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

91d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/57788787?v=4)[Sébastien Muler](/maintainers/mulertech)[@mulertech](https://github.com/mulertech)

---

Top Contributors

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

---

Tags

symfonysecurityspamcaptchaformbot-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

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M376](/packages/easycorp-easyadmin-bundle)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k246.0M11.1k](/packages/symfony-framework-bundle)[sulu/sulu

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

1.3k1.4M196](/packages/sulu-sulu)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19564.8M1.6k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M396](/packages/drupal-core-recommended)[shopware/storefront

Storefront for Shopware

674.4M209](/packages/shopware-storefront)

PHPackages © 2026

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