PHPackages                             alikdex/yii2-recaptcha - 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. alikdex/yii2-recaptcha

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

alikdex/yii2-recaptcha
======================

reCaptcha without curl

2.0.0(8y ago)166[1 issues](https://github.com/AlikDex/yii2-recaptcha/issues)MITPHP

Since Aug 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/AlikDex/yii2-recaptcha)[ Packagist](https://packagist.org/packages/alikdex/yii2-recaptcha)[ RSS](/packages/alikdex-yii2-recaptcha/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (2)Dependencies (2)Versions (5)Used By (0)

Google reCAPTCHA widget for Yii2
================================

[](#google-recaptcha-widget-for-yii2)

Based on google reCaptcha API 2.0.

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

[](#installation)

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

- Either run

```
php composer.phar require --prefer-dist "alikdex/yii2-recaptcha" "2.0.0"

```

or add

```
"alikdex/yii2-recaptcha" : "2.0.0"
```

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

- [Sign up for an reCAPTCHA API keys](https://www.google.com/recaptcha/admin#createsite).
- 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' => [
    'container' => [
        'definitions' => [
            Adx\ReCaptcha\ReCaptcha::class => [
                'siteKey' => 'Your site key',
            ],
            Adx\ReCaptcha\ReCaptchaValidator::class => [
                'secret' => 'Your secret key',
            ],
        ],
    ],
    ...
],
```

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

```
public $reCaptcha;

public function rules()
{
  return [
      // ...
      [['captcha'], \Adx\ReCaptcha\ReCaptchaValidator::class],
  ];
}
```

or just

```
public function rules()
{
  return [
      // ...
      [[], \Adx\ReCaptcha\ReCaptchaValidator::class],
  ];
}
```

Usage
-----

[](#usage)

For example:

```

```

or

```
