PHPackages                             dario\_swain/re-captcha-validator - 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. dario\_swain/re-captcha-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

dario\_swain/re-captcha-validator
=================================

Google reCaptcha FormType and Validator for Symfony applications.

1.0.5(10y ago)857.5k—5%4[1 PRs](https://github.com/DarioSwain/ReCaptchaValidator/pulls)MITPHPPHP &gt;=5.3.3

Since Feb 4Pushed 10y ago2 watchersCompare

[ Source](https://github.com/DarioSwain/ReCaptchaValidator)[ Packagist](https://packagist.org/packages/dario_swain/re-captcha-validator)[ RSS](/packages/dario-swain-re-captcha-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (6)Versions (7)Used By (0)

Simple Google reCAPTCHA FormType and Validator Component for Symfony2 applications
==================================================================================

[](#simple-google-recaptcha-formtype-and-validator-component-for-symfony2-applications)

[![SensioLabsInsight](https://camo.githubusercontent.com/cc26b954bba136ac6dc5665d810e6187fa290cca4b72e79e56fd73741dd332c0/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f36353431366337392d326337362d346231642d623439302d3664306635373737383333372f6269672e706e67)](https://insight.sensiolabs.com/projects/65416c79-2c76-4b1d-b490-6d0f57778337)[![Latest Stable Version](https://camo.githubusercontent.com/7a2bf6791fd4ad8e058682e6b40ad0a01791089458a44d314c385e86dd04524a/68747470733a2f2f706f7365722e707567782e6f72672f646172696f5f737761696e2f72652d636170746368612d76616c696461746f722f762f737461626c65)](https://packagist.org/packages/dario_swain/re-captcha-validator)[![Build Status](https://camo.githubusercontent.com/99ee364cf12b6b96ff0e8dba106b321a0e34e8572655b3c4c58ff463f7d0438e/68747470733a2f2f7472617669732d63692e6f72672f446172696f537761696e2f52654361707463686156616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/DarioSwain/ReCaptchaValidator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f7f4585e9761f5ba0f60a869a874a29c24a2451403fce045ab7e8c8965a70ea6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f446172696f537761696e2f52654361707463686156616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/DarioSwain/ReCaptchaValidator/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/d7800b0b68194b2eff569e1bdcd37bd73e1d9388fd38007e5a7957c7ca5b3740/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f446172696f537761696e2f52654361707463686156616c696461746f722f62616467652e737667)](https://coveralls.io/r/DarioSwain/ReCaptchaValidator)[![License](https://camo.githubusercontent.com/a8bc00ad206881b92e83b18b536db2821087a5f1a66ffed6a9d7951cf6dca662/68747470733a2f2f706f7365722e707567782e6f72672f646172696f5f737761696e2f72652d636170746368612d76616c696461746f722f6c6963656e7365)](https://packagist.org/packages/dario_swain/re-captcha-validator)

Really light and simple reCAPTCHA component for Symfony Frameworks, it's not a Bundle, you can reconfigure all components whatever you like.

You can find full documentation about Google reCAPTCHA API v2 [here](http://developers.google.com/recaptcha/intro).

Installation
------------

[](#installation)

You can install this package with [Composer](http://getcomposer.org/). Add next lines to your composer.json file:

```
{
    "require": {
        "dario_swain/re-captcha-validator": "dev-master"
    },
    "scripts": {
        "post-install-cmd": [
            "DS\\Component\\ReCaptchaValidator\\Composer\\ScriptHandler::replaceViews"
        ],
        "post-update-cmd": [
            "DS\\Component\\ReCaptchaValidator\\Composer\\ScriptHandler::replaceViews"
        ]
    },
}
```

To use this package with php version ~ 5.3 use version ~ 1.0

Usage Example
-------------

[](#usage-example)

Add public and private keys, and configure reCAPTCHA Form Type like a service, provide next configuration to application bundle service configuration (service.yml):

```
parameters:
    ds_recaptcha_public_key:  #YOUR_PUBLIC_KEY#
    ds_recaptcha_private_key: #YOUR_PRIVATE_KEY#

services:
    ds.form.type.recaptcha:
            class: DS\Component\ReCaptchaValidator\Form\ReCaptchaType
            arguments: ['@request_stack', %ds_recaptcha_public_key%, %ds_recaptcha_private_key%, %locale%]
            tags:
                - { name: form.type, alias: ds_recaptcha }
```

After this you can add reCAPTCHA type to your custom form:

```
