PHP code example of artack / recaptcha-enterprise-bundle
1. Go to this page and download the library: Download artack/recaptcha-enterprise-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/ */
artack / recaptcha-enterprise-bundle example snippets
use Artack\RecaptchaEnterpriseBundle\Form\RecaptchaEnterpriseType;
use Artack\RecaptchaEnterpriseBundle\Validator\RecaptchaEnterprise;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
final class ContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('email', EmailType::class)
->add('message', TextareaType::class)
->add('recaptchaToken', RecaptchaEnterpriseType::class, [
'action_name' => 'contact', # sent to Google; also matched when validating
'script_csp_nonce' => '...' # optional generated nonce to be used in the script tag
'constraints' => [
new RecaptchaEnterprise(
minScore: 0.7, # optional
actionName: 'contact',
),
],
]);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.