PHPackages                             andanteproject/recaptcha-bundle - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. andanteproject/recaptcha-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

andanteproject/recaptcha-bundle
===============================

A Symfony Bundle to easily integrate Google reCAPTCHA into Symfony Form

1.1.2(4y ago)34.1k↓44.1%MITPHPPHP ^7.4 || ^8.0

Since Feb 25Pushed 4y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (10)Versions (6)Used By (0)

[![Andante Project Logo](https://github.com/andanteproject/recaptcha-bundle/raw/main/andanteproject-logo.png?raw=true)](https://github.com/andanteproject/recaptcha-bundle/blob/main/andanteproject-logo.png?raw=true)

Google ReCAPTCHA Bundle
=======================

[](#google-recaptcha-bundle)

#### Symfony Bundle - [AndanteProject](https://github.com/andanteproject)

[](#symfony-bundle---andanteproject)

[![Latest Version](https://camo.githubusercontent.com/ffe69c84fb86aa785eb547d3535c365aa1bbc5ebaa93033e192d804994f26b0e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f616e64616e746570726f6a6563742f7265636170746368612d62756e646c652e737667)](https://github.com/andanteproject/recaptcha-bundle/releases)[![Github actions](https://github.com/andanteproject/recaptcha-bundle/actions/workflows/workflow.yml/badge.svg?branch=main)](https://github.com/andanteproject/recaptcha-bundle/actions/workflows/workflow.yml/badge.svg?branch=main)[![Framework](https://camo.githubusercontent.com/b628021a4dd90b0e5ff8808b2a3ece2736a0d3f15e5a035d7f8bc688b8dd783a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d342e78253743352e78253743362e782d696e666f726d6174696f6e616c3f5374796c653d666c6174266c6f676f3d73796d666f6e79)](https://camo.githubusercontent.com/b628021a4dd90b0e5ff8808b2a3ece2736a0d3f15e5a035d7f8bc688b8dd783a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d342e78253743352e78253743362e782d696e666f726d6174696f6e616c3f5374796c653d666c6174266c6f676f3d73796d666f6e79)[![Php7](https://camo.githubusercontent.com/c582fc136b4ed23cead60c28938899492ec83e353258d8c01c690196d4e62c8c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253230372e34253743382e782d696e666f726d6174696f6e616c3f7374796c653d666c6174266c6f676f3d706870)](https://camo.githubusercontent.com/c582fc136b4ed23cead60c28938899492ec83e353258d8c01c690196d4e62c8c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253230372e34253743382e782d696e666f726d6174696f6e616c3f7374796c653d666c6174266c6f676f3d706870)[![PhpStan](https://camo.githubusercontent.com/ecf361cdd6dfc8d69061b1cd65e7414a6e6293da2837adfd795aded2e52cc31a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d737963636573733f7374796c653d666c6174266c6f676f3d706870)](https://camo.githubusercontent.com/ecf361cdd6dfc8d69061b1cd65e7414a6e6293da2837adfd795aded2e52cc31a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d737963636573733f7374796c653d666c6174266c6f676f3d706870)

A Symfony Bundle to easily integrate [Google reCAPTCHA](https://www.google.com/recaptcha/) into [Symfony Form](https://symfony.com/doc/current/forms.html).

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

[](#requirements)

Symfony 4.x-6.x and PHP 7.4-8.x.

Install
-------

[](#install)

Via [Composer](https://getcomposer.org/):

```
$ composer require andanteproject/recaptcha-bundle
```

Features
--------

[](#features)

- Add [Google reCAPTCHA](https://www.google.com/recaptcha/) to your [Symfony Form](https://symfony.com/doc/current/forms.html) just like you do with every other `FormType`;
- Works like magic ✨.

Install
-------

[](#install-1)

After [install](#install), make sure you have the bundle registered in your symfony bundles list (`config/bundles.php`):

```
return [
    /// bundles...
    Andante\ReCaptchaBundle\AndanteReCaptchaBundle::class => ['all' => true],
    /// bundles...
];
```

This should have been done automagically if you are using [Symfony Flex](https://flex.symfony.com). Otherwise, just register it by yourself.

Configuration
-------------

[](#configuration)

Create a new `andante_re_captcha.yaml` configuration file and sets [Google ReCAPTCHA v2 `secret` and `site_key`](http://www.google.com/recaptcha/admin).

```
andante_re_captcha:
  secret: 'put_here_your_google_recaptcha_v2_secret'
  site_key: 'put_here_your_google_recaptcha_v2_site_key'
```

### Dev/test environment Configuration

[](#devtest-environment-configuration)

**Please note:** If you don't want to be annoyed by recaptcha in your development/test environment, just use `secret key` and `site key` you can find in this [Google ReCAPTCHA documentation page](https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do). Furthermore, you can create a `test` configuration to disable `Andante\ReCaptchaBundle\Validator\Constraint\ReCaptchaValidator` in `test` environment:

```
andante_re_captcha:
  enable_validation: false #default: true
```

Usage
-----

[](#usage)

After this, you can add `Andante\ReCaptchaBundle\Form\ReCaptchaType` Form type in your forms like you always do with other types.

```
