2017 © Pedro Peláez
 

library re-captcha-validator

Google reCaptcha FormType and Validator for Symfony applications.

image

dario_swain/re-captcha-validator

Google reCaptcha FormType and Validator for Symfony applications.

  • Thursday, March 10, 2016
  • by dario_swain
  • Repository
  • 2 Watchers
  • 5 Stars
  • 10,141 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 3 Open issues
  • 7 Versions
  • 9 % Grown

The README.md

Simple Google reCAPTCHA FormType and Validator Component for Symfony2 applications

SensioLabsInsight Latest Stable Version Build Status Scrutinizer Code Quality Coverage Status License, (*1)

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

You can find full documentation about Google reCAPTCHA API v2 here., (*3)

Installation

You can install this package with Composer. Add next lines to your composer.json file:, (*4)

``` json { "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" ] }, }, (*5)


To use this package with php version ~ 5.3 use version ~ 1.0 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): ``` yaml 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:, (*6)

``` php <?php, (*7)

namespace AcmeBundle\Form;, (*8)

use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface;, (*9)

class ContactType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('message', 'textarea') /** In type add your form alias **/ ->add('captcha', 'ds_recaptcha', array('mapped' => false)) ->add('send', 'submit'); }, (*10)

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        /** This option is require, because reCaptcha api.js add extra field "g-recaptcha-response" to form **/
        'allow_extra_fields' => true,
    ));
}

}, (*11)


Next step, you need to add form_theme to your form view, it seems like that: ```twig {% extends 'AcmeBundle::layout.html.twig' %} {% form_theme form 'DS/ReCaptcha/views/form_div_layout.html.twig' %} {% block content %} {{ form_start(form) }} {{ form_widget(form) }} {{ form_end(form) }} {% endblock %}

If you need to customize from widget, feel free to change template in %kernel_root%/Resources/DS/ReCaptcha/views/form_div_layout.twig, (*12)

Copyright (c) 2015 Ilya Pokamestov dario_swain@yahoo.com., (*13)

The Versions

10/03 2016

dev-master

9999999-dev

Google reCaptcha FormType and Validator for Symfony applications.

  Sources   Download

MIT

The Requires

 

The Development Requires

form validator security symfony captcha recaptcha

10/03 2016

1.0.5

1.0.5.0

Google reCaptcha FormType and Validator for Symfony applications.

  Sources   Download

MIT

The Requires

 

The Development Requires

form validator security symfony captcha recaptcha

09/11 2015

1.0.4

1.0.4.0

Google reCaptcha FormType and Validator for Symfony applications.

  Sources   Download

MIT

The Requires

 

The Development Requires

form validator security symfony captcha recaptcha

26/06 2015

1.0.3

1.0.3.0

Google reCaptcha FormType and Validator for Symfony applications.

  Sources   Download

MIT

The Requires

 

The Development Requires

form validator security symfony captcha recaptcha

25/06 2015

1.0.2

1.0.2.0

Google reCaptcha FormType and Validator for Symfony applications.

  Sources   Download

MIT

The Requires

 

The Development Requires

form validator security symfony captcha recaptcha

09/02 2015

1.0.1

1.0.1.0

Google reCaptcha FormType and Validator for Symfony applications.

  Sources   Download

MIT

The Requires

 

The Development Requires

form validator security symfony captcha recaptcha

04/02 2015

1.0.0

1.0.0.0

Google reCaptcha FormType and Validator for Symfony applications.

  Sources   Download

MIT

The Requires

 

form validator security symfony captcha recaptcha