kleegroup/google-recaptcha-bundle

Symfony Google Recaptcha 表单类型

安装量 2,832

依赖者: 2

建议者: 0

安全性: 0

星标: 6

关注者: 12

分支: 2

开放问题: 1

类型:symfony-bundle

1.0.3 2018-11-30 09:24 UTC

This package is not auto-updated.

Last update: 2024-09-13 23:21:20 UTC


README

Symfony 3 的 Google Recaptcha 包,支持代理配置。

步骤 1:设置包

1) 将 GoogleRecaptchaBundle 添加到项目中

composer require kleegroup/google-recaptcha-bundle

2) 启用包

在内核中启用包

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new KleeGroup\GoogleReCaptchaBundle\GoogleReCaptchaBundle(),
    );
}

步骤 2:配置包

// config.yml
[...]
google_re_captcha:
   site_key: [Google_site_key]
   secret_key: [Google_secret_key]
   enabled: true/false
   ajax: true/false
   locale_key: [locale_key]
   http_proxy:
       host: [IP or hostname]
       port: [Port]

步骤 3:使用

   public function buildForm( FormBuilderInterface $builder, array $options)
   {
       [...]
       $builder
           ->add('recaptcha', ReCaptchaType::class, 
                   [
                         'mapped'      => false,
                         'constraints' => [
                             new ReCaptcha(),
                         ],
                   ]
           );
       [...]
       
   }