mikemix/mxrecaptcha
最新稳定版本:1.2.0
Composer 安装命令:
composer require mikemix/mxrecaptcha
包简介
ZF2 Form integration with v2.0 reCaptcha
README 文档
README
Easy ZF2 form integration with reCaptcha v2.0
Installation
- Install with Composer
php composer.phar require 'mikemix/mxrecaptcha:~1.0'(we follow the rules of Semantic Versioning) - Load the
mxreCaptchamodule in yourconfig/application.config.phpfile - Copy the dist config file
cp vendor/mikemix/mxrecaptcha/config/mxrecaptcha.local.php.dist config/autoload/mxrecaptcha.local.phpand write your private and public key in it - You are ready to go!
Usage
First of all, add the reCaptcha element to your form. Example form class below:
namespace App\Form; use Zend\Form\Form; class AddForm extends Form { public function init() { $this->add([ 'name' => 'recaptcha', // or any name of your choice 'type' => 'mxreCaptcha', // this is important, use our reCaptcha component 'options' => [ 'label' => 'Prove you are human', ], ]); // or // This element behaves as any other element. // Aside from that, you can pass custom grecaptcha.render parameters // available at the docs // https://developers.google.com/recaptcha/docs/display#render_param // by setting widget_options key in the options, for example: $this->add([ 'name' => 'recaptcha', 'type' => 'mxreCaptcha', 'options' => [ 'label' => 'Prove you are human', 'widget_options' => [ 'theme' => 'dark', ], ], ]); $this->add([ 'name' => 'submit', 'type' => 'submit', ]); } }
Example controller
namespace App\Controller; use App\Form\AddForm; use Zend\Mvc\Controller\AbstractActionController; class FormController extends AbstractActionController { public function indexAction() { $form = $this->getServiceLocator()->get('FormElementManager') ->get(AddForm::class); if ($this->request->isPost()) { $form->setData($this->request->getPost()); if ($form->isValid()) { $this->flashMessenger()->addSuccessMessage('Success!'); return $this->redirect()->toRoute('home'); } } return [ 'form' => $form ]; } }
Example view
<?php /** @var App\Form\AddForm $form */ $form = $this->form->prepare(); ?> <?= $this->form()->openTag($form) ?> <?= $this->formCollection($form) ?> <?= $this->form()->closeTag() ?>
Localization
By default, Polish translation for localized error messages is available out of the box.
To create custom translation for your application, simply copy the pl.po file from the language directory
and name it accordingly to match your translator locale setting (for example fr_ca.po). Finally translate
error messages and compile this file to *.mo. Put those two files inside the language directory.
If you are willing to share your translation, please make a pull request.
Unit tests
This modules comes up with unit tests. phpUnit is required to run the suite:
- Clone this repository
git clone https://github.com/mikemix/mxreCaptcha.git - Navigate to it
cd mxreCaptcha - Download composer
php -r "readfile('https://getcomposer.org/installer');" | php - Install dependencies
php composer.phar update - Run suite
phpunit
mikemix/mxrecaptcha 适用场景与选型建议
mikemix/mxrecaptcha 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 862 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「zf2」 「recaptcha」 「Zend Framework」 「zf2 form」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mikemix/mxrecaptcha 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mikemix/mxrecaptcha 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mikemix/mxrecaptcha 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LosLog provides some log utility
EdpModuleLayouts is very simple Laminas module for making module-specific layouts insanely easy.
Client library for reCAPTCHA with proxy support, a free service that protects websites from spam and abuse.
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.
A simple and easy to use Google ReCaptcha v3 package for Laravel
Polyfill for mb_ereg(), mb_eregi(), mb_ereg_match(), and mb_ereg_replace*() functions; primary use case is for mbstring on Windows 7.4+
统计信息
- 总下载量: 862
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-09