1. Go to this page and download the library: Download vihuvac/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/ */
vihuvac / recaptcha-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Vihuvac\Bundle\RecaptchaBundle\VihuvacRecaptchaBundle(),
);
}
public function buildForm(FormBuilder $builder, array $options)
{
// ...
$builder->add("recaptcha", "vihuvac_recaptcha");
// ...
}
use Vihuvac\Bundle\RecaptchaBundle\Form\Type\VihuvacRecaptchaType as RecaptchaType;
public function buildForm(FormBuilder $builder, array $options)
{
// ...
$builder->add("recaptcha", RecaptchaType::class);
// ...
}
use Vihuvac\Bundle\RecaptchaBundle\Form\Type\VihuvacRecaptchaType as RecaptchaType;
public function buildForm(FormBuilder $builder, array $options)
{
// ...
$builder->add("recaptcha", RecaptchaType::class, array(
"attr" => array(
"options" => array(
"theme" => "light",
"type" => "audio",
"size" => "normal",
"defer" => false, // Set true if you want to use the Ajax API.
"async" => false // Set true if you want to use the Ajax API.
)
)
));
// ...
}
use Vihuvac\Bundle\RecaptchaBundle\Form\Type\VihuvacRecaptchaType as RecaptchaType;
public function buildForm(FormBuilder $builder, array $options)
{
// ...
$builder->add("recaptcha", RecaptchaType::class, array(
"attr" => array(
"options" => array(
"theme" => "light",
"type" => "image",
"size" => "invisible", // Set size to the invisible reCAPTCHA.
"defer" => false, // Set true if you are using the Ajax API.
"async" => false, // Set true if you are using the Ajax API.
"callback" => "onReCaptchaSuccess", // Callback will be set by default if it's not defined (along with JS function that validates the form on success).
"bind" => "buttonSubmit", // This is the form submit button id (html attribute).
// ...
)
)
));
// ...
}
use Vihuvac\Bundle\RecaptchaBundle\Form\Type\VihuvacRecaptchaType as RecaptchaType;
public function buildForm(FormBuilder $builder, array $options)
{
// ...
$builder->add("recaptcha", RecaptchaType::class, array(
"language" => "en",
// ...
));
// ...
}
use Vihuvac\Bundle\RecaptchaBundle\Validator\Constraints as Recaptcha;
/**
* @Recaptcha\IsTrue
*/
public $recaptcha;
use Vihuvac\Bundle\RecaptchaBundle\Form\Type\VihuvacRecaptchaType as RecaptchaType;
use Vihuvac\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue;
public function buildForm(FormBuilder $builder, array $options)
{
// ...
$builder->add("recaptcha", RecaptchaType::class, array(
"attr" => array(
"options" => array(
"theme" => "light",
"type" => "audio",
"size" => "normal"
)
),
"mapped" => false,
"constraints" => array(
new RecaptchaTrue()
)
));
// ...