luyadev/yii2-recaptcha-widget 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

luyadev/yii2-recaptcha-widget

最新稳定版本:1.0.0

Composer 安装命令:

composer require luyadev/yii2-recaptcha-widget

包简介

Yii2 Google reCAPTCHA v2 and v3 widget

README 文档

README

LUYA Logo

Google reCAPTCHA widget

THIS IS A FORK FROM THE ARCHIVED HIMIKLAB REPOSITORY. THE MAIN GOAL IS TO SUPPORT LATEST PHP VERSIONS

Tests Total Downloads

Installation

composer require luyadev/yii2-recaptcha-widget

Sign up for an reCAPTCHA API keys and configure the component in your configuration file.

'components' => [ 'reCaptcha' => [ 'class' => 'luyadev\recaptcha\ReCaptchaConfig', 'siteKeyV2' => 'your siteKey v2', 'secretV2' => 'your secret key v2', 'siteKeyV3' => 'your siteKey v3', 'secretV3' => 'your secret key v3', ], ...

Add ReCaptchaValidator2 or ReCaptchaValidator3 as validator into your model, do not forget to set those attributes as required.

public $reCaptcha; public function rules() { return [ [['reCaptcha'], 'required'], [['reCaptcha'], \luyadev\recaptcha\ReCaptchaValidator2::class, 'uncheckedMessage' => 'Please confirm that you are not a bot.'], ]; }
public $reCaptcha; public function rules() { return [ [['reCaptcha'], 'required'], [['reCaptcha'], \luyadev\recaptcha\ReCaptchaValidator3::class, 'threshold' => 0.5, 'action' => 'homepage'], ]; }

Usage in the view files for ActiveForm:

NOTE: Disable ajax validation for ReCaptcha field!

$form->field($model, 'reCaptcha')->widget(\luyadev\recaptcha\ReCaptcha2::class) // v2
$form->field($model, 'reCaptcha')->widget(\luyadev\recaptcha\ReCaptcha3::class, ['action' => 'homepage']) // v3

as widgets:

\luyadev\recaptcha\ReCaptcha2::widget([ 'name' => 'reCaptcha', 'widgetOptions' => ['class' => 'col-sm-offset-3'], ]);

v3

\luyadev\recaptcha\ReCaptcha3::widget([ 'name' => 'reCaptcha', 'action' => 'homepage', 'widgetOptions' => ['class' => 'col-sm-offset-3'], ]);

统计信息

  • 总下载量: 13.85k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 108
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固