PHPackages                             recurloop/laravel-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. recurloop/laravel-recaptcha

ActiveLibrary[Security](/categories/security)

recurloop/laravel-recaptcha
===========================

Laravel package for Recaptcha V3.

03PHP

Since Dec 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/RecurLoop/laravel-recaptcha)[ Packagist](https://packagist.org/packages/recurloop/laravel-recaptcha)[ RSS](/packages/recurloop-laravel-recaptcha/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Recaptcha
=================

[](#laravel-recaptcha)

Laravel package for Recaptcha V3

The main motivation for this project was the fact that I could not find an existing package for recaptcha v3 that met two conditions:

- possible reading of scores for requests (without rejecting if the score is too low)
- the recaptcha token should be generated just before sending the request (and not when generating the page), which may result in an expired token.

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

[](#installation)

To get started, use Composer to add the package to your project's dependencies:

```
composer require recurloop/laravel-recaptcha:dev-main

```

Add `RECAPTCHA_SITE_KEY` and `RECAPTCHA_SECRET_KEY` to your `.env` file. (You can get them [here](https://www.google.com/recaptcha/admin#list))

```
RECAPTCHA_SITE_KEY=sitekey
RECAPTCHA_SECRET_KEY=secret

```

Optionally, you can publish the config file:

```
php artisan vendor:publish --provider="RecurLoop\Recaptcha\Providers\RecaptchaServiceProvider"

```

Usage
-----

[](#usage)

#### Init Recaptcha

[](#init-recaptcha)

recaptcha v3 should be loaded on every page to track user activity:

```

    ...
    {!! Recaptcha::initJs() !!}

```

#### Forms

[](#forms)

a recaptcha token should be sent with each form along with the name of the action performed:

```

    Send message

```

or

```

    Send message

```

#### Request validation

[](#request-validation)

Register the middleware in your Kernel.php file.

```
protected $routeMiddleware = [
    ...
    'recaptcha' => \App\Http\Middleware\VerifyRecaptchaScore::class,
    ...
];
```

You can then reject requests if they do not reach the minimum specified in the config.

```
Route::post('contact', fn() => null)->middleware('recaptcha:contact');
```

or with given minimum

```
Route::post('contact', fn() => null)->middleware('recaptcha:contact,0.7');
```

#### Check the score

[](#check-the-score)

Alternatively, you can check if the score has been reached directly in the code:

```
use RecurLoop\Recaptcha\Exceptions\InvalidTokenException;
use RecurLoop\Recaptcha\Facades\Recaptcha;

try {
    // Regardless of the action
    Recaptcha::checkScore(request());
    // Including a token (the token will be invalid if the action does not match)
    Recaptcha::checkScore(request(), 'contact');
    // Taking into account the action and the minimum score
    Recaptcha::checkScore(request(), 'contact', 0.75);
} catch (InvalidTokenException $exception) {
    ...
}
```

#### Retrieve the score

[](#retrieve-the-score)

Alternatively, you can retrieve the score

```
use RecurLoop\Recaptcha\Exceptions\InvalidTokenException;
use RecurLoop\Recaptcha\Facades\Recaptcha;

try {
    // Regardless of the action
    $score = Recaptcha::retrieveScore(request());
    // Including a token (the token will be invalid if the action does not match)
    $score = Recaptcha::retrieveScore(request(), 'contact');
} catch (InvalidTokenException $exception) {
    ...
}
```

#### Hiding the ReCAPTCHA Badge

[](#hiding-the-recaptcha-badge)

Add to your CSS file:

```
.grecaptcha-badge { visibility: hidden !important; }
```

#### Localization

[](#localization)

By default, the package follows the default application locale, which is defined in `config/app.php`. If you want to change this behavior, you can specify what locale to use by adding a new environment variable :

```
RECAPTCHA_LOCALE=en

```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4344b327d9ef2255d9c307ff7fee65445fb74b0378d74460d22f3052254557a?d=identicon)[RecurLoop](/maintainers/RecurLoop)

---

Top Contributors

[![RecurLoop](https://avatars.githubusercontent.com/u/34611934?v=4)](https://github.com/RecurLoop "RecurLoop (3 commits)")

### Embed Badge

![Health badge](/badges/recurloop-laravel-recaptcha/health.svg)

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M212](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M112](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

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