anysrv / recaptcha-bundle
reCAPTCHA v2 form field integration for Symfony 3
Installs: 1 210
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Type:symfony-bundle
This package has no released version yet, and little information is available.
README
reCAPTCHA v2 form field integration for Symfony 3
Installation
Step 1: Use composer and enable the bundle
To install AnysrvRecaptchaBundle with Composer just type in your terminal:
php composer.phar require anysrv/recaptcha-bundle
Now, Composer will automatically download all required files, and install them
for you. All that is left to do is to update your AppKernel.php
file and
register the new bundle:
// in AppKernel::registerBundles() $bundles = array( // ... new Anysrv\RecaptchaBundle\AnysrvRecaptchaBundle(), // ... );
Step 2: Configure the bundle
Add the following settings to your config file:
# app/config/config.yml anysrv_recaptcha: sitekey: enter_your_sitekey_from_google secret: enter_your_secret_from_google
If you want to overwrite the locale you must set the locale in your config:
# app/config/config.yml anysrv_recaptcha: // ... overwrite_locale: cn
Basic usage
When creating a new form class add the following line to create the field:
use Anysrv\RecaptchaBundle\Form\Type\AnysrvRecaptchaType; use Anysrv\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue; public function buildForm(FormBuilder $builder, array $options) { // ... $builder->add('recaptcha', AnysrvRecaptchaType::class, array( 'mapped' => false, 'constraints' => array( new RecaptchaTrue(), ), )); // ... }