yiirocks / recaptcha
Google reCAPTCHA v2 and v3 widget and server-side validator for Yii3.
dev-master / 1.0.x-dev
2026-06-11 17:16 UTC
Requires
- php: >=8.3
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 || ^2.0
- yiisoft/html: ^3.13 || ^4.0
- yiisoft/request-provider: ^1.3
- yiisoft/translator: ^3.0
- yiisoft/validator: ^2.5
- yiisoft/widget: ^2.2
Requires (Dev)
- friendsofphp/php-cs-fixer: @stable
- nyholm/psr7: @stable
- phpunit/phpunit: @stable
- psr/container: ^2.0
- vimeo/psalm: @stable
- yiisoft/translator-message-php: ^1.1
This package is auto-updated.
Last update: 2026-06-12 21:53:44 UTC
README
Google reCAPTCHA v2 and v3 widget and server-side validator for Yii3.
Requirements
- PHP 8.3+
- PSR-18 HTTP client + PSR-17 factories
Installation
composer require yiirocks/recaptcha
You also need a PSR-18 client and PSR-17 factories:
composer require guzzlehttp/guzzle nyholm/psr7
Usage
reCAPTCHA v2
use YiiRocks\Recaptcha\RecaptchaV2; use YiiRocks\Recaptcha\RecaptchaV2Theme; use YiiRocks\Recaptcha\RecaptchaV2Size; echo RecaptchaV2::widget() ->withSiteKey($siteKey) ->withTheme(RecaptchaV2Theme::Dark) ->withSize(RecaptchaV2Size::Normal);
reCAPTCHA v3
use YiiRocks\Recaptcha\RecaptchaV3; echo RecaptchaV3::widget() ->withSiteKey($siteKey) ->withAction('login') ->withFormId('login-form');
Validation
use YiiRocks\Recaptcha\RecaptchaV2Rule; class LoginForm { #[RecaptchaV2Rule] public string $gRecaptchaResponse = ''; }
License
MIT. See LICENSE.md.