PHP code example of vuillaume-agency / symfony-turnstile
1. Go to this page and download the library: Download vuillaume-agency/symfony-turnstile 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/ */
vuillaume-agency / symfony-turnstile example snippets
// In your form
->add('captcha', TurnstileType::class)
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use VuillaumeAgency\TurnstileBundle\Type\TurnstileType;
class ContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('email', EmailType::class)
->add('message', TextareaType::class)
->add('captcha', TurnstileType::class, [
'label' => false,
])
->add('submit', SubmitType::class);
}
}
->add('captcha', TurnstileType::class, [
'label' => false,
'attr' => [
'data-theme' => 'dark', // 'light', 'dark', or 'auto'
'data-size' => 'compact', // 'normal' or 'compact'
'data-action' => 'contact', // Custom action name for analytics
],
])
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
$builder
->add('captcha', TurnstileType::class)
->add('submit', SubmitType::class, ['label' => 'Send']);