承接 alkurn/yii2-recaptcha 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

alkurn/yii2-recaptcha

Composer 安装命令:

composer require alkurn/yii2-recaptcha

包简介

Yii2 Google reCAPTCHA widget

README 文档

README

Based on reCaptcha API 2.0.

Installation

The preferred way to install this extension is through composer.

  • Either run
php composer.phar require --prefer-dist "alkurn/yii2-recaptcha" "dev-master"

or add

"alkurn/yii2-recaptcha" : "*"

to the require section of your application's composer.json file.

  • Sign up for an reCAPTCHA API keys.

  • Configure the component in your configuration file (web.php). The parameters siteKey and secret are optional. But if you leave them out you need to set them in every validation rule and every view where you want to use this widget. If a siteKey or secret is set in an individual view or validation rule that would overrule what is set in the config.

'components' => [
    'reCaptcha' => [
        'name' => 'reCaptcha',
        'class' => 'alkurn\recaptcha\ReCaptcha',
        'siteKey' => 'your siteKey',
        'secret' => 'your secret key',
    ],
    ...
  • Add ReCaptchaValidator in your model, for example:
public $reCaptcha;

public function rules()
{
  return [
      // ...
      [['reCaptcha'], \alkurn\recaptcha\ReCaptchaValidator::className(), 'secret' => 'your secret key']
  ];
}

or just

public function rules()
{
  return [
      // ...
      [[], \alkurn\recaptcha\ReCaptchaValidator::className(), 'secret' => 'your secret key']
  ];
}

or simply

public function rules()
{
  return [
      // ...
      [[], \alkurn\recaptcha\ReCaptchaValidator::className()]
  ];
}

Usage

For example:

<?= $form->field($model, 'reCaptcha')->widget(
    \alkurn\recaptcha\ReCaptcha::className(),
    ['siteKey' => 'your siteKey']
) ?>

or

<?= \alkurn\recaptcha\ReCaptcha::widget([
    'name' => 'reCaptcha',
    'siteKey' => 'your siteKey',
    'widgetOptions' => ['class' => 'col-sm-offset-3']
]) ?>

or

<?= $form->field($model, 'reCaptcha')->widget(\alkurn\recaptcha\ReCaptcha::className()) ?>

or simply

<?= \alkurn\recaptcha\ReCaptcha::widget(['name' => 'reCaptcha']) ?>

Resources

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-06