prugala/recaptcha-bundle

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

reCAPTCHA v3 for Symfony 的软件包

安装次数: 32,616

依赖关系: 0

建议者: 0

安全: 0

星级: 14

关注者: 1

分支: 6

公开问题: 8

类型:symfony-bundle

1.3.2 2020-02-26 10:15 UTC

README

此存储库已归档,不再维护。

请使用:https://github.com/excelwebzone/EWZRecaptchaBundle

RecaptchaBundle

reCAPTCHA v3 for Symfony 的软件包

Latest Stable Version Total Downloads License

Build Status

安装

composer require prugala/recaptcha-bundle

AppKernel.php 文件中注册软件包

new PR\Bundle\RecaptchaBundle\PRRecaptchaBundle()

配置

pr_recaptcha:
    public_key: 'public key'
    secret_key: 'secret key'
    enabled: false # optional / default value: true - you can disable it for local or test env
    score_threshhold: 'score' # optional / default value: 0.5
    hide_badge: true # optional / default value: false *
    host: 'www.google.com' # optional / default value: www.google.com **

* 当您隐藏徽章时,请通知访客网站已实现 reCAPTCHA:https://developers.google.com/recaptcha/docs/faq#hiding-badge

** 如果您计划全局使用 reCAPTCHA,请使用主机 www.recaptcha.net。更多信息:https://developers.google.com/recaptcha/docs/faq#can-i-use-recaptcha-globally

在 Symfony 4.4 及更高版本中,您需要自己通过在 config/packages.twig.yaml 中添加来注册表单主题。

twig:
    form_themes: ['@PRRecaptcha/Form/recaptcha.html.twig']

如何使用

将类型为 RecaptchaType 的字段添加到您的表单中,例如

->add('captcha', RecaptchaType::class)

可用的选项

->add('captcha', RecaptchaType::class, [
    'script_nonce_csp' => $nonce,
    'action_name' => 'contact_form'
])
  • script_nonce_csp: Content-Security-Policy 标头的 Nonce
  • action_name: 表单特定操作名称

待办事项

  1. 支持版本 v2
  2. 等待建议 :)