PHP code example of andanteproject / recaptcha-bundle

1. Go to this page and download the library: Download andanteproject/recaptcha-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andanteproject / recaptcha-bundle example snippets


return [
    /// bundles...
    Andante\ReCaptchaBundle\AndanteReCaptchaBundle::class => ['all' => true],
    /// bundles...
];


use Andante\ReCaptchaBundle\Form\ReCaptchaType;
use Symfony\Component\Form\AbstractType;

class RegistrationFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            // ...
            // All your form fields
            // ...
            ->add('recaptcha', ReCaptchaType::class);
    }
}

$builder->add('recaptcha', ReCaptchaType::class, [
    'theme' => 'dark', // default is "light"
    'size' =>  'compact' // default is "normal"
]);

$builder->add('recaptcha', ReCaptchaType::class, [
    'constraints' => [
        // Default value is Constraints\NotBlank + Constraint\Recaptcha 
    ]
]);
yaml
andante_re_captcha:
  secret: 'put_here_your_google_recaptcha_v2_secret'
  site_key: 'put_here_your_google_recaptcha_v2_site_key'