PHPackages                             friendsofhyperf/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. [Security](/categories/security)
4. /
5. friendsofhyperf/recaptcha

ActiveLibrary[Security](/categories/security)

friendsofhyperf/recaptcha
=========================

The Google recaptcha component for Hyperf.

v3.2.1(2mo ago)11.1kMITPHP

Since May 24Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/friendsofhyperf/recaptcha)[ Packagist](https://packagist.org/packages/friendsofhyperf/recaptcha)[ Fund](https://hdj.me/sponsors/)[ GitHub Sponsors](https://github.com/huangdijia)[ RSS](/packages/friendsofhyperf-recaptcha/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (18)Versions (100)Used By (0)

ReCaptcha
=========

[](#recaptcha)

[中文说明](README_CN.md)

A Google ReCaptcha component for Hyperf.

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

[](#installation)

```
composer require friendsofhyperf/recaptcha
```

Configuration
-------------

[](#configuration)

Publish `config/autoload/recaptcha.php` before using the middleware or validator:

```
php bin/hyperf.php vendor:publish friendsofhyperf/recaptcha
```

Set `RECAPTCHA_SECRET_V2_KEY` for reCAPTCHA v2 and `RECAPTCHA_SECRET_V3_KEY` for reCAPTCHA v3, or configure `v2.secret_key` and `v3.secret_key` in the published file. The `default` key selects the version used when no version is passed explicitly.

Usage
-----

[](#usage)

- Define Middleware

```
namespace App\Middleware;

use FriendsOfHyperf\ReCaptcha\Middleware\ReCaptchaMiddleware;

class V3CaptchaMiddleware extends ReCaptchaMiddleware
{
    protected string $version = 'v3';
    protected string $action = 'register';
    protected float $score = 0.35;
    protected string $hostname;
}

class V2CaptchaMiddleware extends ReCaptchaMiddleware
{
    protected string $version = 'v2';
    protected string $action = 'register';
    protected float $score = 0.35;
    protected string $hostname;
}
```

- Validator Usage

```
