formatz / contao-recaptcha-bundle
Google reCAPTCHA v2 form field for Contao 5
Package info
gitlab.com/formatz/contao-recaptcha-bundle
Type:contao-bundle
pkg:composer/formatz/contao-recaptcha-bundle
Requires
- php: ^8.1
- contao/core-bundle: ^5.3
- psr/log: ^1.1 || ^2.0 || ^3.0
- symfony/config: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/http-client-contracts: ^3.1
- symfony/http-foundation: ^6.4 || ^7.0
- symfony/http-kernel: ^6.4 || ^7.0
- symfony/yaml: ^6.4 || ^7.0
Requires (Dev)
- contao/manager-plugin: ^2.0
Suggests
None
Provides
None
Conflicts
- contao/core: *
- contao/manager-plugin: <2.0 || >=3.0
Replaces
None
This package is auto-updated.
Last update: 2026-12-03 13:05:08 UTC
README
Google reCAPTCHA v2 ("I'm not a robot") form field for Contao 5.
Requirements
- Contao 5.3 or newer
- PHP 8.1 or newer (tested up to PHP 8.5)
Version 1.x of this bundle supports Contao 4.
Configuration
- Create a reCAPTCHA v2 "I'm not a robot" checkbox key pair in the Google reCAPTCHA admin console.
- In the Contao back end, go to System > Settings > reCaptcha configuration and enter the site key and the secret key.
- Add a reCaptcha I am not a robot field to your form.
The Google script is loaded only on pages that display the field. If your site sends a
Content-Security-Policy, the field adds the Google reCAPTCHA sources to script-src and frame-src.
If the verification with Google cannot be done (missing secret key, network error), the form is not submitted and the error is written to the Contao system log. Google answers a wrong secret key like an invalid token, so a wrong key is not logged: if every submission is refused, check the keys first.
Upgrading from 1.x
- The field template is now
form_recaptcha(it extendsform_row, like the core form fields). Rename anyrecaptcha.html5override in yourtemplatesfolder and adapt it. - The access key, tab index and add submit button options were removed, as in the Contao 5 core.
allow_url_fopenis no longer required when the PHPcurlextension is available.- The widget class was renamed from
Formatz\ContaoRecaptcha\FormReCaptchatoFormatz\ContaoRecaptchaBundle\Widget\Frontend\FormReCaptcha. Update any code that extends or references it.
For developers
The verification is done by the formatz_contao_recaptcha.verifier service
(Formatz\ContaoRecaptchaBundle\Recaptcha\RecaptchaVerifier), which you can reuse or decorate.
It uses the application's http_client service, so the HTTP client configuration of the project (proxy, etc.) applies.