dynamikaweb/yii2-captcha 问题修复 & 功能扩展

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

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

dynamikaweb/yii2-captcha

最新稳定版本:1.0.0

Composer 安装命令:

composer require dynamikaweb/yii2-captcha

包简介

Component for google reCaptcha or hCaptcha.

README 文档

README

php version pkg version license quality build

Features

  • Custom alignment
  • Centered by default
  • Not jQuery dependent
  • Not printable by default
  • Development keys by default
  • Better responsive Improvements
  • Support for google reCaptcha and also hCaptcha
  • Support for multiple validators, widgets and keys at the same time

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require dynamikaweb/yii2-captcha "*"

or add

"dynamikaweb/yii2-captcha": "*"

to the require section of your composer.json file.

Usage

Widget using input name

  • View file
<?php 

use dynamikaweb\captcha\Captcha;
?>

<?=Captcha::widget([
  'siteKey' => 'XXX',
  'name' => 'captcha',
  'pos' => Captcha::POS_LEFT // or Captcha::POS_CENTER or Captcha::POS_RIGHT (optional)
  'size' => Captcha::SIZE_COMPACT // or Captcha::SIZE_NORMAL (optional)
  'type' => Captcha::TYPE_RECAPTCHA // or Captcha::TYPE_HCAPTCHA 
])?>

Widget using model (site key in model file)

  • Model file
<?php 

namespace app\models;

use dynamikaweb\captcha\CaptchaValidator;

class SomeModel extends yii\base\Model
{
  public $captcha;

  public function rules()
  {
    return [
      [['captcha'], CaptchaValidator::classname(),
        'type' => CaptchaValidator::TYPE_RECAPTCHA, // or CaptchaValidator::TYPE_HCAPTCHA
        'siteKey' => 'XXX', // (optional)
        'secret' => 'XXX'
      ]
    ];
  }
}
  • View file
<?php 

use dynamikaweb\captcha\Captcha;
?>

<?=$form->attribute($model, 'captcha')->widget('dynamikaweb\captcha\Captcha')?>

Widget using model (site key in view file)

  • Model file
<?php 

namespace app\models;

use dynamikaweb\captcha\CaptchaValidator;

class SomeModel extends yii\base\Model
{
  public $captcha;

  public function rules()
  {
    return [
      [['captcha'], CaptchaValidator::classname(),
        'type' => CaptchaValidator::TYPE_RECAPTCHA, // or CaptchaValidator::TYPE_HCAPTCHA
        'secret' => 'XXX'
      ]
    ];
  }
}
  • View file
<?php 

use dynamikaweb\captcha\Captcha;
?>

<?=$form->attribute($model, 'captcha')->widget('dynamikaweb\captcha\Captcha', [
  'siteKey' => 'XXX',
  'size' => Captcha::SIZE_COMPACT // or Captcha::SIZE_NORMAL (optional)
  'pos' => Captcha::POS_LEFT // or Captcha::POS_CENTER or Captcha::POS_RIGHT (optional)
])?>

dynamika soluções web This project is under BSD-3-Clause license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2021-12-16