sfue/re-captcha-bundle

Google reCAPTCHA symfony 表单类型和验证器

安装: 17

依赖项: 0

建议者: 0

安全: 0

星级: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

v1.0.1 2018-05-13 21:41 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:41:57 UTC


README

安装

通过 Composer 安装包

$ composer require sfue/re-captcha-bundle

将包添加到您的 AppKernel

// app/AppKernel.php

<?php

public function registerBundles()
{
    $bundles = array(
        // ...
        new new Sfue\ReCaptchaBundle\SfueReCaptchaBundle(),
    );
}

将包的主题添加到您的 twig 配置中

sfue_re_captcha:
    site_key: 'your Google reCAPTCHA site key'
    secret: 'your Google reCAPTCHA secret'

将包的主题添加到您的 twig 配置中

# Twig Configuration
twig:
    form_themes:
        - '@SfueReCaptcha/Form/fields.html.twig'

在需要 reCAPTCHA 字段的任何表单中使用 ReCaptchaType

public function buildForm(FormBuilderInterface $builder, array $options) {
	$builder
		// ...
		->add('recaptcha', ReCaptchaType::class)
	;
}