2017 © Pedro Peláez
 

library google-recaptcha-bundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

image

nietonfir/google-recaptcha-bundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 0 Open issues
  • 8 Versions
  • 18 % Grown

The README.md

GoogleReCaptchaBundle

ReCAPTCHA is a free CAPTCHA service that protects websites from spam and abuse. This bundle uses the GoogleReCaptcha library or validating a users "No CAPTCHA reCAPTCHA" response and provides a custom form type, a custom validation constraint as well as a validator to use with the Symfony Form Component., (*1)

Latest Stable Version Latest Unstable Version License, (*2)

Installation

The recommended way to install GoogleReCaptchaBundle is through Composer., (*3)

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version of GoogleReCaptcha:, (*4)

composer require "nietonfir/google-recaptcha-bundle"

Or add GoogleReCaptchaBundle in your composer.json, (*5)

"require": {
    "nietonfir/google-recaptcha-bundle": "v0.0.3"
}

and tell Composer to install the library:, (*6)

``` bash composer update "nietonfir/google-recaptcha-bundle", (*7)


After installing, don't forget to enable the bundle: ```php <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Nietonfir\Google\ReCaptchaBundle\NietonfirGoogleReCaptchaBundle(), ); }

Configuration

Add the following simple configuration to your config.yml., (*8)

nietonfir_google_recaptcha:
    sitekey: <your_site_key_here>
    secret: <and_your_secret_here>
    validation: '<your_form_name>'

Multiple forms

ReCaptcha can also be added to different forms (while not on the same page!):, (*9)

nietonfir_google_recaptcha:
    validation: [ '<your_form_name_A>', '<your_form_name_B>' ]

Custom form field name

The form field name containing the recaptcha response, which defaults to recaptcha, can be customized as well:, (*10)

nietonfir_google_recaptcha:
    validation:
        forms:
            - {form_name: '<your_form_name_A>', field_name: 'recaptcha'}
            - {form_name: '<your_form_name_B>', field_name: 'recaptcha'}

Additionally you have to add the corresponding form field themes depending on your used templating engine in config.yml., (*11)

# Twig
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form_themes:
        - 'NietonfirGoogleReCaptchaBundle:Form:fields.html.twig'

# PHP
framework:
    templating:
        form:
            resources:
                - 'NietonfirGoogleReCaptchaBundle:Form'

Usage

Using the Bundle is dead simple:, (*12)

  1. Create your form type as usual
  2. Add a field using the recaptcha field type, (*13)

    use Nietonfir\Google\ReCaptchaBundle\Form\Type\ReCaptchaType;
    
    $builder->add('recaptcha', ReCaptchaType::class);
    
  3. Add the necessary javascript library to your template, (*14)

    <script src='https://www.google.com/recaptcha/api.js' async defer></script>
    
  4. Make your controller implement ReCaptchaValidationInterface, (*15)

    use Nietonfir\Google\ReCaptchaBundle\Controller\ReCaptchaValidationInterface;
    
    class DefaultController extends Controller implements ReCaptchaValidationInterface
    

Now when form->isValid() is called, the submitted reCAPTCHA response is validated against the Google API. Be advised that both the form and the field name used have to be set in config.yml., (*16)

TODOs

  • [x] Add some info() to the form & field name config values in Configuration.php
  • [x] Translate the error messages returned from the Google API to something more meaningful
  • [ ] Update documentation
  • [ ] Add some more examples
  • [x] Add missing unit tests

The Versions

17/04 2017

dev-master

9999999-dev https://github.com/nietonfir/GoogleReCaptchaBundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

  Sources   Download

MIT

The Requires

 

The Development Requires

security captcha google recaptcha no captcha recaptcha

17/04 2017

v0.2.1

0.2.1.0 https://github.com/nietonfir/GoogleReCaptchaBundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

  Sources   Download

MIT

The Requires

 

The Development Requires

security captcha google recaptcha no captcha recaptcha

25/03 2017

v0.2.0

0.2.0.0 https://github.com/nietonfir/GoogleReCaptchaBundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

  Sources   Download

MIT

The Requires

 

The Development Requires

security captcha google recaptcha no captcha recaptcha

17/12 2016

0.0.x-dev

0.0.9999999.9999999-dev https://github.com/nietonfir/GoogleReCaptchaBundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

  Sources   Download

MIT

The Requires

 

The Development Requires

security captcha google recaptcha no captcha recaptcha

17/12 2016

v0.0.3

0.0.3.0 https://github.com/nietonfir/GoogleReCaptchaBundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

  Sources   Download

MIT

The Requires

 

The Development Requires

security captcha google recaptcha no captcha recaptcha

16/12 2016

v0.1.0

0.1.0.0 https://github.com/nietonfir/GoogleReCaptchaBundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

  Sources   Download

MIT

The Requires

 

The Development Requires

security captcha google recaptcha no captcha recaptcha

28/11 2016

v0.0.2

0.0.2.0 https://github.com/nietonfir/GoogleReCaptchaBundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

  Sources   Download

MIT

The Requires

 

The Development Requires

security captcha google recaptcha no captcha recaptcha

13/01 2015

v0.0.1

0.0.1.0 https://github.com/nietonfir/GoogleReCaptchaBundle

Symfony2 bundle for integrating nietonfir/google-recaptcha (simplifying the server-side validation of Google's 'No CAPTCHA reCAPTCHA')

  Sources   Download

MIT

The Requires

 

The Development Requires

security captcha google recaptcha no captcha recaptcha