sc0 / yandex-smartcaptcha-bundle
An Yandex Smart Captcha Symfony integration
Installs: 3 034
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=8.1
- symfony/config: ^6.1 | ^7.0
- symfony/dependency-injection: ^6.1 | ^7.0
- symfony/form: ^6.1 | ^7.0
- symfony/http-kernel: ^6.1 | ^7.0
- symfony/validator: ^6.1 | ^7.0
This package is auto-updated.
Last update: 2025-09-09 22:42:56 UTC
README
Yandex Smart Captcha Symfony 6.1+ integration
Installation
Install library via composer:
composer require sc0/yandex-smartcaptcha-bundle
Add it to bundles list:
# bundles.php <?php return [ // ... Sc\YandexSmartCaptchaBundle\YandexSmartCaptchaBundle::class => ['all' => true], // ... ];
Configure keys:
# /config/packages/config.yaml yandex_smart_captcha: secret_key: Your_Server_Key site_key: Your_Client_Key
Use new Type in forms
use Sc\YandexSmartCaptchaBundle\Form\Type\YandexSmartCaptchaType; // ... $builder->add('captcha', YandexSmartCaptchaType::class); // ...
Use custom HTML wrapper around the captcha:
# 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 constraint in forms
use Sc\YandexSmartCaptchaBundle\Form\Type\YandexSmartCaptchaType; use Sc\YandexSmartCaptchaBundle\Validator\Constraints\YandexSmartCaptcha; // ... $builder->add('captcha', YandexSmartCaptchaType::class, [ 'constraints' => [ new YandexSmartCaptcha() ], ]); // ...