andanteproject/recaptcha-bundle
Composer 安装命令:
composer require andanteproject/recaptcha-bundle
包简介
A Symfony Bundle to easily integrate Google reCAPTCHA into Symfony Form
关键字:
README 文档
README
Google ReCAPTCHA Bundle
Symfony Bundle - AndanteProject
A Symfony Bundle to easily integrate Google reCAPTCHA into Symfony Form.
Requirements
Symfony 4.x-6.x and PHP 7.4-8.x.
Install
Via Composer:
$ composer require andanteproject/recaptcha-bundle
Features
- Add Google reCAPTCHA to your Symfony Form just like you do with every other
FormType; - Works like magic ✨.
Install
After install, make sure you have the bundle registered in your symfony bundles list (config/bundles.php):
return [ /// bundles... Andante\ReCaptchaBundle\AndanteReCaptchaBundle::class => ['all' => true], /// bundles... ];
This should have been done automagically if you are using Symfony Flex. Otherwise, just register it by yourself.
Configuration
Create a new andante_re_captcha.yaml configuration file and sets Google ReCAPTCHA v2 secret and site_key.
andante_re_captcha: secret: 'put_here_your_google_recaptcha_v2_secret' site_key: 'put_here_your_google_recaptcha_v2_site_key'
Dev/test environment Configuration
Please note: If you don't want to be annoyed by recaptcha in your development/test environment, just use secret key and site key you can find in this Google ReCAPTCHA documentation page.
Furthermore, you can create a test configuration to disable Andante\ReCaptchaBundle\Validator\Constraint\ReCaptchaValidator in test environment:
andante_re_captcha: enable_validation: false #default: true
Usage
After this, you can add Andante\ReCaptchaBundle\Form\ReCaptchaType Form type in your forms like you always do with other types.
<?php use Andante\ReCaptchaBundle\Form\ReCaptchaType; use Symfony\Component\Form\AbstractType; class RegistrationFormType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder // ... // All your form fields // ... ->add('recaptcha', ReCaptchaType::class); } }
Done! 🎉
You also have 2 options to change ReCAPTCHA theme or size.
$builder->add('recaptcha', ReCaptchaType::class, [ 'theme' => 'dark', // default is "light" 'size' => 'compact' // default is "normal" ]);
Using the option 'theme' => 'dark' is especially useful if your app has a dark mode.
How to change validation process
Validation is handled by Andante\ReCaptchaBundle\Validator\Constraint\ReCaptchaValidator, which is a default constraint inside ReCaptchaType options.
If you want to replace it with your own or disable it for whatever reason, just empty/replace form type constraints option.
$builder->add('recaptcha', ReCaptchaType::class, [ 'constraints' => [ // Default value is Constraints\NotBlank + Constraint\Recaptcha ] ]);
Built with love ❤️ by AndanteProject team.
andanteproject/recaptcha-bundle 适用场景与选型建议
andanteproject/recaptcha-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.13k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「php」 「symfony-bundle」 「PHP7」 「php74」 「google-recaptcha」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 andanteproject/recaptcha-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 andanteproject/recaptcha-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 andanteproject/recaptcha-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
Symfony bundle for the Rekapager library
Symfony bundle for Cloudflare integration: trusted proxies, real client IP detection, forwarded headers.
Bundle Symfony DaplosBundle
A very minimal Mailchimp integration for Symfony
Alfabank REST API integration
统计信息
- 总下载量: 4.13k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-25
