PHPackages                             ethsam/easy-hcaptcha - 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. ethsam/easy-hcaptcha

ActiveSymfony-bundle[Validation &amp; Sanitization](/categories/validation)

ethsam/easy-hcaptcha
====================

A modern, zero-config Symfony bundle for hCaptcha: server-side verification, Twig widget, Form Type and Validation Constraint.

v2.0.0(2mo ago)12MITPHPPHP &gt;=8.1CI passing

Since Apr 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/ethsam/easy-hcaptcha)[ Packagist](https://packagist.org/packages/ethsam/easy-hcaptcha)[ RSS](/packages/ethsam-easy-hcaptcha/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)Dependencies (12)Versions (5)Used By (0)

easy-hcaptcha
=============

[](#easy-hcaptcha)

[![CI](https://github.com/ethsam/easy-hcaptcha/actions/workflows/ci.yml/badge.svg)](https://github.com/ethsam/easy-hcaptcha/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/85af2f16cd004c0e2204b4c70d4b2b41c3e8960b57f08040ca1161e513605fff/68747470733a2f2f636f6465636f762e696f2f67682f65746873616d2f656173792d68636170746368612f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/ethsam/easy-hcaptcha)[![Latest Stable Version](https://camo.githubusercontent.com/8d0760143ffabe26e08c891bb901af665b592a67b7d9ba38a441ec1636ec6928/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f65746873616d2f656173792d68636170746368612e737667)](https://packagist.org/packages/ethsam/easy-hcaptcha)[![License](https://camo.githubusercontent.com/e114d8398d62134aa282af529ffedee594545f0de2f9ef9847fdc180d92694a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f65746873616d2f656173792d68636170746368612e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/79b2373692c5e928d72e8aeaf20df19be78ed9277c170c501e5cfd4a15d1921e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f65746873616d2f656173792d68636170746368612e737667)](composer.json)

A modern, zero-config **Symfony bundle** for [hCaptcha](https://www.hcaptcha.com/): server-side verification, Twig widget, Form Type and Validation Constraint — ready in under a minute.

> **Languages / Langues / Idiomas:** [English](docs/en/index.md) · [Français](docs/fr/index.md) · [Español](docs/es/index.md)

---

Features
--------

[](#features)

- **Zero-config** install via Symfony Flex
- Strict-typed `HcaptchaVerifier` returning a rich `HcaptchaResponse` value object (`success`, `errorCodes`, `hostname`, `score` for Enterprise, …)
- Symfony **Form Type** (`HcaptchaType`) with auto-attached validator
- Symfony **Validation Constraint** (`#[Hcaptcha]`) for any DTO/property
- **Twig functions**: `hcaptcha_script()`, `hcaptcha_widget()`, `hcaptcha_invisible_widget()`
- HTTPS-only verify URL, attribute name allow-list, JS callback identifier check
- Test-mode toggle (`enabled: false`) — no HTTP call, always succeeds
- PSR-3 logging on transport failures
- 100% PHP 8.1+ / Symfony 6.4 LTS · 7.x compatible

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

[](#requirements)

- PHP **8.1** or higher
- Symfony **6.4 LTS** or **7.x**

Quick install
-------------

[](#quick-install)

```
composer require ethsam/easy-hcaptcha
```

Then in `.env`:

```
HCAPTCHA_SITE_KEY=your_public_site_key
HCAPTCHA_SECRET_KEY=your_secret_key
```

And in `config/packages/easy_hcaptcha.yaml`:

```
easy_hcaptcha:
    site_key:   '%env(HCAPTCHA_SITE_KEY)%'
    secret_key: '%env(HCAPTCHA_SECRET_KEY)%'
```

30-second usage
---------------

[](#30-second-usage)

```
{# templates/contact.html.twig #}
{{ hcaptcha_script() }}

    {{ hcaptcha_widget() }}
    Send

```

```
// In your controller — pick your favourite style:

// 1) Form Type (recommended — auto-validated)
$form = $this->createFormBuilder()
    ->add('email', EmailType::class)
    ->add('captcha', HcaptchaType::class)
    ->getForm();

// 2) Validation Constraint on a DTO
class ContactDto {
    #[\Ethsam\EasyHcaptcha\Validator\Constraint\Hcaptcha]
    public ?string $captchaToken = null;
}

// 3) Manual call (full control)
public function submit(Request $r, HcaptchaVerifierInterface $verifier): Response
{
    $result = $verifier->verify($r->request->get('h-captcha-response'), $r->getClientIp());
    if (!$result->isSuccess()) {
        return $this->redirectToRoute('contact');
    }
    // ...
}
```

Documentation
-------------

[](#documentation)

Full documentation in three languages:

EnglishFrançaisEspañol[📖 Index](docs/en/index.md)[📖 Index](docs/fr/index.md)[📖 Índice](docs/es/index.md)[Installation](docs/en/installation.md)[Installation](docs/fr/installation.md)[Instalación](docs/es/installation.md)[Configuration](docs/en/configuration.md)[Configuration](docs/fr/configuration.md)[Configuración](docs/es/configuration.md)[Twig usage](docs/en/usage-twig.md)[Utilisation Twig](docs/fr/usage-twig.md)[Uso con Twig](docs/es/usage-twig.md)[Form Type](docs/en/usage-form-type.md)[Form Type](docs/fr/usage-form-type.md)[Form Type](docs/es/usage-form-type.md)[Validator](docs/en/usage-validator.md)[Validateur](docs/fr/usage-validator.md)[Validador](docs/es/usage-validator.md)[Controller](docs/en/usage-controller.md)[Contrôleur](docs/fr/usage-controller.md)[Controlador](docs/es/usage-controller.md)[Upgrade from 1.x](docs/en/upgrade-from-1.x.md)[Migration depuis 1.x](docs/fr/upgrade-from-1.x.md)[Migración desde 1.x](docs/es/upgrade-from-1.x.md)Testing your app without hitting the API
----------------------------------------

[](#testing-your-app-without-hitting-the-api)

In `config/packages/test/easy_hcaptcha.yaml`:

```
easy_hcaptcha:
    enabled: false   # verifier returns success without any network call
```

Contributing
------------

[](#contributing)

Pull requests welcome. Run the test suite locally:

```
composer install
vendor/bin/phpunit
```

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for a detailed history of releases.

License
-------

[](#license)

Released under the [MIT License](LICENSE) — see the file for details.

Originally authored by [Samuel ETHEVE](https://github.com/ethsam).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance86

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

69d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/27362741?v=4)[Samuel Ethève](/maintainers/ethsam)[@ethsam](https://github.com/ethsam)

---

Top Contributors

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

---

Tags

symfonybundlevalidationspamcaptchaformbothcaptcha

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ethsam-easy-hcaptcha/health.svg)

```
[![Health](https://phpackages.com/badges/ethsam-easy-hcaptcha/health.svg)](https://phpackages.com/packages/ethsam-easy-hcaptcha)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[chameleon-system/chameleon-base

The Chameleon System core.

1028.6k5](/packages/chameleon-system-chameleon-base)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[prestashop/prestashop

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

9.1k17.8k](/packages/prestashop-prestashop)

PHPackages © 2026

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