PHPackages                             vitalygallyamov/yii2-coinhive-captcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. vitalygallyamov/yii2-coinhive-captcha

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

vitalygallyamov/yii2-coinhive-captcha
=====================================

Yii2 Coin-Hive captcha widget

0.0.5(8y ago)134MITPHP

Since Oct 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/vitalygallyamov/yii2-coinhive-captcha)[ Packagist](https://packagist.org/packages/vitalygallyamov/yii2-coinhive-captcha)[ RSS](/packages/vitalygallyamov-yii2-coinhive-captcha/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (1)Versions (7)Used By (0)

Coinhive captcha widget for Yii2
================================

[](#coinhive-captcha-widget-for-yii2)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

- Either run

```
php composer.phar require --prefer-dist "vitalygallyamov/yii2-coinhive-captcha" "*"

```

or add

```
"vitalygallyamov/yii2-coinhive-captcha" : "*"
```

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

- [Sign up for an coin hive captcha API keys](https://coinhive.com/account/signup).
- 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' => [
    'chCaptcha' => [
        'class' => 'vitalygallyamov\yii2\chcaptcha\ChComponent',
        'siteKey' => 'your siteKey',
        'secretKey' => 'your secretKey'
    ],
    ...
```

- Add `ChCaptchaValidator` in your model, for example:

```
public function rules()
{
  return [
      // ...
      [['captcha'], \vitalygallyamov\yii2\chcaptcha\ChCaptchaValidator::className()]
  ];
}
```

or simply

```
public function rules()
{
  return [
      // ...
      [[], \vitalygallyamov\yii2\chcaptcha\ChCaptchaValidator::className()]
  ];
}
```

Usage
-----

[](#usage)

For example:

```
