PHPackages                             brussens/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. brussens/yii2-recaptcha

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

brussens/yii2-recaptcha
=======================

Google ReCaptcha v2.0 Yii 2.x.x extension

1.1.0(7y ago)724.9k↓38.5%5[1 PRs](https://github.com/brussens/yii2-recaptcha/pulls)MITPHPPHP &gt;=5.4.0

Since Jan 27Pushed 6y ago3 watchersCompare

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

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

Google ReCaptcha v2.0 Yii 2.x.x extension
=========================================

[](#google-recaptcha-v20-yii-2xx-extension)

[![Latest Stable Version](https://camo.githubusercontent.com/3bd2a751301d4e650b0ce3c0d68f0b0a4220ce968fe372d0839f2f170f383f0f/68747470733a2f2f706f7365722e707567782e6f72672f6272757373656e732f796969322d7265636170746368612f762f737461626c65)](https://packagist.org/packages/brussens/yii2-recaptcha)[![Total Downloads](https://camo.githubusercontent.com/fb32b81092c4276ec734acc0aef8f148c03b7bbd61a73afeaaaca6fc838ccdd6/68747470733a2f2f706f7365722e707567782e6f72672f6272757373656e732f796969322d7265636170746368612f646f776e6c6f616473)](https://packagist.org/packages/brussens/yii2-recaptcha)[![License](https://camo.githubusercontent.com/0294c7fa385da757c0af3b5990d2241f622fadd08cc2fa71f5e027bca09ab472/68747470733a2f2f706f7365722e707567782e6f72672f6272757373656e732f796969322d7265636170746368612f6c6963656e7365)](https://packagist.org/packages/brussens/yii2-recaptcha)

> The main difference from the similar extensions is that this one doesn't require an application component with constant name, such as `\Yii::$app->recaptcha` or something.

Install
-------

[](#install)

Either run

```
php composer.phar require --prefer-dist brussens/yii2-recaptcha "*"

```

or add

```
"brussens/yii2-recaptcha": "*"

```

to the require section of your `composer.json` file.

Add to your bootstrap file:

```
$container->setSingleton(\ReCaptcha\ReCaptcha::class, function($container, $params, $config) {
    return new \ReCaptcha\ReCaptcha('your secret');
});

$container->set(\brussens\yii2\extensions\recaptcha\Widget::class, function($container, $params, $config) {
    return new \brussens\yii2\extensions\recaptcha\Widget('your site key', \Yii::$app->language, $config);
});
```

Since Yii 2.0.11 you can also configure the container in the 'container' section of the app configuration:

```
'container' => [
    'definitions' => [
        \brussens\yii2\extensions\recaptcha\Widget::class => function($container, $params, $config) {
            return new \brussens\yii2\extensions\recaptcha\Widget('your site key', \Yii::$app->language, $config);
        }
    ],
    'singletons' => [
         \ReCaptcha\ReCaptcha::class => function($container, $params, $config) {
             return new \ReCaptcha\ReCaptcha('your secret');
         }
    ]
]
```

Add in your model validation rules

```
public function rules()
{
    return [
        ...
        ['verifyCode', \brussens\yii2\extensions\recaptcha\Validator::className()],
        ...
    ];
}
```

Add in your view

```
echo $form->field($model, 'verifyCode')->widget(\brussens\yii2\extensions\recaptcha\Widget::className());
```

If you use Pjax or multiple widgets on page

```
echo $form->field($model, 'verifyCode')->widget(
    \brussens\yii2\extensions\recaptcha\Widget::className(), [
    'options' => [
        'id' => 'insert-unique-widget-id'
    ]
]);
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~288 days

Total

3

Last Release

2823d ago

Major Versions

1.1.0 → v2.x-dev2018-08-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/436a63d75811386f486820ea2de0060dc20d95294beee6555edf6ea7c03bc367?d=identicon)[brussens](/maintainers/brussens)

---

Tags

googlerecaptchayii2yii

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brussens-yii2-recaptcha/health.svg)

```
[![Health](https://phpackages.com/badges/brussens-yii2-recaptcha/health.svg)](https://phpackages.com/packages/brussens-yii2-recaptcha)
```

###  Alternatives

[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1243.1k1](/packages/skeeks-yii2-google-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
