PHPackages                             walkboy/yii2-hcaptcha - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. walkboy/yii2-hcaptcha

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

walkboy/yii2-hcaptcha
=====================

Yii2 hCaptcha widget

1.0.0(6mo ago)012MITPHPPHP ^8.0

Since Oct 15Pushed 6mo agoCompare

[ Source](https://github.com/wa1kb0y/yii2-hcaptcha)[ Packagist](https://packagist.org/packages/walkboy/yii2-hcaptcha)[ RSS](/packages/walkboy-yii2-hcaptcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

hCaptcha widget for Yii2
========================

[](#hcaptcha-widget-for-yii2)

This package based on archived [Yii2 Recaptcha Widget](https://github.com/himiklab/yii2-recaptcha-widget) and adapted for hCaptcha.

![Packagist](https://camo.githubusercontent.com/30d28110abaddd60d5d5ff5e2f48233dde01dab9a06292132ea67b585c5fe127/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77616c6b626f792f796969322d68636170746368612e737667) ![Packagist](https://camo.githubusercontent.com/34d8611c1dc42a8daa3f05194ea057c0abd4173f889f5059fee9c7bb24adc236/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77616c6b626f792f796969322d68636170746368612e737667) ![license](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)

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

[](#installation)

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

Either run

```
composer require "walkboy/yii2-hcaptcha" "*"

```

or add

```
"walkboy/yii2-hcaptcha" : "*"
```

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

- [Sign up for an hCaptcha API keys](https://dashboard.hcaptcha.com/signup).
- Configure the component in your configuration file (web.php or main.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' => [
    'hCaptcha' => [
        'class' => \walkboy\hcaptcha\HCaptchaConfig',
        'siteKey' => 'your siteKey',
        'secret' => 'your secret',
    ],
    ...
],
```

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

```
public $verifyKey;

public function rules()
{
  return [
      // ...
      [['verifyKey'], \walkboy\hcaptcha\HCaptchaValidator::class,
        'secret' => 'your secret key', // unnecessary if hCaptcha is already configured
        'uncheckedMessage' => 'Please confirm that you are not a robot.'],
  ];
}
```

Usage
-----

[](#usage)

For example:

```
