prugala / recaptcha-bundle
此软件包已被弃用,不再维护。未建议替代软件包。
reCAPTCHA v3 for Symfony 的软件包
1.3.2
2020-02-26 10:15 UTC
Requires
- php: ^7.1
- google/recaptcha: ^1.1
- symfony/form: ^2.8 || ^3.0 || ^4.0 || ^5.0
- symfony/framework-bundle: ^2.8 || ^3.0 || ^4.0 || ^5.0
- symfony/validator: ^2.8 || ^3.0 || ^4.0 || ^5.0
- twig/twig: ^2.0 || ^3.0
Requires (Dev)
- phpunit/phpunit: ^7 || ^8
This package is auto-updated.
Last update: 2021-02-11 08:17:41 UTC
README
此存储库已归档,不再维护。
请使用:https://github.com/excelwebzone/EWZRecaptchaBundle
RecaptchaBundle
reCAPTCHA v3 for Symfony 的软件包
安装
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: 表单特定操作名称
待办事项
- 支持版本 v2
- 等待建议 :)