ed.sukharev/re-captcha-validator
Composer 安装命令:
composer require ed.sukharev/re-captcha-validator
包简介
Google reCaptcha FormType and Validator for Symfony forms.
README 文档
README
Really light and simple reCAPTCHA component for Symfony Forms component (does not require Symfony Framework), it's not a Bundle, you can reconfigure all components whatever you like.
You can find full documentation about Google reCAPTCHA API v2 here.
Installation
You can install this package with Composer. Run following:
composer require ed.sukharev/re-captcha-validator
Usage Example
Add public and private keys, and configure reCAPTCHA Form Type like a service. After this you can add reCAPTCHA type to your form:
<?php namespace AcmeBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; class ContactType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('message', 'textarea') /** In type add your form alias **/ ->add('captcha', 'ds_re_captcha', array('mapped' => false)) ->add('send', 'submit'); } public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( /** This option is require, because reCaptcha api.js add extra field "g-recaptcha-response" to form **/ 'allow_extra_fields' => true, )); } }
Next step, you need to render the widget onto your view. Follows the example for Twig template engine, but it should be similar to others.
Either inline it in your form:
{% extends 'AcmeBundle::layout.html.twig' %}
{% form_theme form _self %}
{% block ds_re_captcha_widget %}
{% spaceless %}
<div class="g-recaptcha" data-sitekey="{{ public_key }}"></div>
<script src="{{ js_api_url }}?hl={{ lang }}" async defer></script>
{% endspaceless %}
{% endblock ds_re_captcha_widget %}
{% block content %}
{{ form(your_form) }}
{% endblock %}
or ship it as separate file (e.g. ds_recaptcha_field.html.twig)
{% block ds_re_captcha_widget %}
{% spaceless %}
<div class="g-recaptcha" data-sitekey="{{ public_key }}"></div>
<script src="{{ js_api_url }}?hl={{ lang }}" async defer></script>
{% endspaceless %}
{% endblock ds_re_captcha_widget %}
and include it in your twig:
{% extends 'AcmeBundle::layout.html.twig' %}
{% form_theme form 'ds_recaptcha_field.html.twig' %}
{% block content %}
{{ form(your_form) }}
{% endblock %}
Copyright
Copyright (c) 2019 Eduard Sukharev sukharev.eh@gmail.com. Copyright (c) 2015 Ilya Pokamestov dario_swain@yahoo.com.
ed.sukharev/re-captcha-validator 适用场景与选型建议
ed.sukharev/re-captcha-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「security」 「form」 「validator」 「recaptcha」 「captcha」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ed.sukharev/re-captcha-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ed.sukharev/re-captcha-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ed.sukharev/re-captcha-validator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
Provide a way to secure accesses to all routes of an symfony application.
It's a barebone security class written on PHP
A Laravel Filament Forms slug field.
Bundle Symfony DaplosBundle
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-17