sc0/yandex-smartcaptcha-bundle

An Yandex Smart Captcha Symfony integration

0.1.0 2022-06-25 23:48 UTC

This package is auto-updated.

Last update: 2024-04-26 12:21:48 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.yaml
yandex_smart_captcha:
    secret_key: foo
    site_key: bar

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 %}