yiirocks/recaptcha

Google reCAPTCHA v2 and v3 field + server-side validator for Yii3.

Maintainers

Package info

github.com/YiiRocks/recaptcha

Homepage

pkg:composer/yiirocks/recaptcha

Transparency log

Fund package maintenance!

YiiRocks

Statistics

Installs: 2 794

Dependents: 1

Suggesters: 1

Stars: 0

Open Issues: 0

v1.0.4 2026-07-24 11:59 UTC

This package is auto-updated.

Last update: 2026-07-24 12:01:16 UTC


README

Google reCAPTCHA v2 and v3 form field + server-side validator for Yii3.

Packagist Version PHP from Packagist Packagist Downloads GitHub License GitHub Workflow Status

Stats for Nerds

Coverage MSI Tests Assertions

Features

  • reCAPTCHA v2 — checkbox/invisible widget field with theme, size, and type options
  • reCAPTCHA v3 — score-based field that fetches its token on form submit (not page load), avoiding surprise challenge popups
  • Server-side validation — PHP attribute rules (RecaptchaV2Rule / RecaptchaV3Rule) verified against Google's siteverify endpoint
  • Score threshold + action matching — v3 rules can enforce a minimum score and an expected action name
  • Zero-config ergonomics — once site keys are set, fields and rules work out of the box via a static registry, no explicit DI wiring needed in views
  • i18n — validation and legal-notice messages are translated through Yii Translator

Requirements

  • PHP 8.3+
  • PSR-18 HTTP client
  • PSR-17 request + stream factories

Installation

composer require yiirocks/recaptcha

A PSR-18 client and PSR-17 factories are required. If your application already has them configured (e.g. via Guzzle, Symfony HTTP Client, or any other implementation), no further setup is needed. If not, install any compatible library, for example:

composer require guzzlehttp/guzzle nyholm/psr7

Documentation

Configuration (site keys, secrets, DI wiring), field options for v2/v3, validation rule parameters, and usage examples are all covered at Yii.rocks.

Testing

# Unit tests
composer phpunit

# Mutation testing
composer infection

# Static analysis
composer psalm

# Code style fixer
composer php-cs-fixer