anysrv/recaptcha-bundle

此包已被放弃,不再维护。未建议替代包。

为 Symfony 3 集成的 reCAPTCHA v2 表单字段

安装数: 1,210

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

类型:symfony-bundle

此包尚无发布版本,信息有限。


README

Build Status Latest Stable Version Total Downloads License Code Climate Test Coverage

为 Symfony 3 集成的 reCAPTCHA v2 表单字段

安装

步骤 1:使用 composer 启用包

要在终端中安装 AnysrvRecaptchaBundle,请输入以下命令

php composer.phar require anysrv/recaptcha-bundle

现在,Composer 将自动下载所有必需的文件,并为您安装它们。接下来需要更新您的 AppKernel.php 文件并注册新包

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Anysrv\RecaptchaBundle\AnysrvRecaptchaBundle(),
    // ...
);

步骤 2:配置包

将以下设置添加到您的配置文件中

# app/config/config.yml

anysrv_recaptcha:
    sitekey: enter_your_sitekey_from_google
    secret: enter_your_secret_from_google

如果您想覆盖地区设置,必须在配置中设置地区

# app/config/config.yml

anysrv_recaptcha:
    // ...
    overwrite_locale: cn

基本用法

在创建新的表单类时,添加以下行以创建字段

use Anysrv\RecaptchaBundle\Form\Type\AnysrvRecaptchaType;
use Anysrv\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue;

public function buildForm(FormBuilder $builder, array $options)
{
    // ...
    $builder->add('recaptcha', AnysrvRecaptchaType::class, array(
        'mapped' => false,
        'constraints' => array(
            new RecaptchaTrue(),
        ),
    ));
    // ...
}