mdoutreluingne / recaptcha-bundle
You can validate your form with invisible recaptchav2 of google
Installs: 145
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.1.3
- google/recaptcha: ^1.2
- symfony/config: ^5.1
- symfony/dependency-injection: ^5.1
- symfony/http-kernel: ^5.1
Requires (Dev)
- symfony/browser-kit: ^5.1
- symfony/framework-bundle: ^5.1
- symfony/phpunit-bridge: ^5.1
This package is auto-updated.
Last update: 2020-12-30 16:24:18 UTC
README
I created this Bundle for educational purposes, with Symfony 5, to be able to share my services with other developers. However this Bundle is functional, you can use it, and allows you to add a Recaptcha v2 invisible from google in your forms !
Install the package with:
composer require mdoutreluingne/recaptcha-bundle
And... that's it! If you're not using Symfony Flex, you'll also
need to enable the mdoutreluingne\RecaptchaBundle\RecaptchaBundle
in your config/bundles.php
file. Like this :
mdoutreluingne\RecaptchaBundle\RecaptchaBundle::class => ['all' => true]
Usage
This bundle provides a service to generate a submit button with
recaptcha v2 invisible from google using RecaptchaSubmitType
type-hint in your class Type:
// src/Form/UnknownType.php use mdoutreluingne\RecaptchaBundle\Type\RecaptchaSubmitType; // ... class UnknownType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder // ... ->add('captcha', RecaptchaSubmitType::class, [ 'label' => 'Submit', 'attr' => [ 'class' => 'btn btn-primary' ] ]) ; } // ... }
Configuration
You need to create and configure the recaptcha.yaml
file in config/packages like this:
# config/packages/recaptcha.yaml recaptcha: key: '%env(GOOGLE_RECAPTCHA_KEY)%' secret: '%env(GOOGLE_RECAPTCHA_SECRET)%'
And after that, integrate your key and google secret vote in the file .env