Yandex Smart Captcha Symfony 6.1+ integration
Install library via composer:
composer require sc0/yandex-smartcaptcha-bundle# bundles.php
<?php
return [
// ...
Sc\YandexSmartCaptchaBundle\YandexSmartCaptchaBundle::class => ['all' => true],
// ...
];# /config/packages/config.yaml
yandex_smart_captcha:
secret_key: Your_Server_Key
site_key: Your_Client_Keyuse Sc\YandexSmartCaptchaBundle\Form\Type\YandexSmartCaptchaType;
// ...
$builder->add('captcha', YandexSmartCaptchaType::class);
// ...# YourType.php
$builder->add('captcha', YandexSmartCaptchaType::class, [
'block_prefix' => 'my_own_captcha_wrapper',
]);{% block my_own_captcha_wrapper_widget %}
<div class="my-captcha-container">
{{ block('yandex_smartcaptcha_widget') }}
</div>
{% endblock my_own_captcha_wrapper_widget %}use Sc\YandexSmartCaptchaBundle\Form\Type\YandexSmartCaptchaType;
use Sc\YandexSmartCaptchaBundle\Validator\Constraints\YandexSmartCaptcha;
// ...
$builder->add('captcha', YandexSmartCaptchaType::class, [
'constraints' => [
new YandexSmartCaptcha()
],
]);
// ...