Search by

yes-corpo / cloudflare-turnstile-bundle

yes-corpo

Cloudflare Turnstile captcha for Symfony forms

Package info

github.com/yes-corpo/cloudflare-turnstile-bundle

Type:symfony-bundle

pkg:composer/yes-corpo/cloudflare-turnstile-bundle

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.1 2026-11-02 16:52 UTC

This package is auto-updated.

Last update: 2026-11-02 16:53:22 UTC


README

Protects Symfony forms with Cloudflare Turnstile: a TurnstileType form type renders the widget, and a Turnstile constraint verifies the token with Cloudflare when the form is submitted.

Symfony PHP
6.4 8.1+
7.4 8.2+
8.x 8.4+

Installation

The bundle has no Flex recipe and both keys are required, so create the configuration first, otherwise the cache:clear run by composer require fails:

# config/packages/cloudflare_turnstile.yaml
cloudflare_turnstile:
    site_key: '%env(TURNSTILE_SITE_KEY)%'
    secret_key: '%env(TURNSTILE_SECRET_KEY)%'
# .env
TURNSTILE_SITE_KEY=
TURNSTILE_SECRET_KEY=

In development and tests, use the Cloudflare test keys.

Then install the bundle:

composer require yes-corpo/cloudflare-turnstile-bundle

Without Symfony Flex, enable the bundle in config/bundles.php:

YesCorpo\Bundle\CloudflareTurnstileBundle\CloudflareTurnstileBundle::class => ['all' => true],

Usage

use YesCorpo\Bundle\CloudflareTurnstileBundle\Form\Type\TurnstileType;

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

The form theme is registered automatically: {{ form_widget(form.captcha) }} renders the widget. The error is displayed by {{ form_errors(form) }}, see error bubbling.

Documentation

  • Usage: form options, error messages, translations, how the verification works.
  • Trolls: optional humorous fake CAPTCHAs shown before the real challenge.

Development

composer install
composer test