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

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

blissjaspis/laravel-recaptcha
=============================

Simple and painless Google reCAPTCHA package for Laravel framework

v2.0.0(2mo ago)0741↑216.7%MITPHPPHP ^8.2

Since Jul 7Pushed 2mo agoCompare

[ Source](https://github.com/blissjaspis/laravel-recaptcha)[ Packagist](https://packagist.org/packages/blissjaspis/laravel-recaptcha)[ Docs](https://github.com/blissjaspis/laravel-recaptcha)[ RSS](/packages/blissjaspis-laravel-recaptcha/feed)WikiDiscussions master Synced 3w ago

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

Laravel ReCAPTCHA
=================

[](#laravel-recaptcha)

**Laravel ReCAPTCHA** is a simple package to embed Google reCAPTCHA in your application.

What is reCAPTCHA?
------------------

[](#what-is-recaptcha)

Google developers says: "reCAPTCHA protects you against spam and other types of automated abuse. Here, we explain how to add reCAPTCHA to your site or application."

You can find further info at [Google reCAPTCHA Developer's Guide](https://developers.google.com/recaptcha/intro "Google reCAPTCHA Developer's Guide")

reCAPTCHA available versions
----------------------------

[](#recaptcha-available-versions)

At this moment there are 3 versions available (for web applications):

- **v3**, the latest ([reCAPTCHA v3](https://developers.google.com/recaptcha/docs/v3))
- **v2 checkbox** or simply reCAPTCHA v2 ([reCAPTCHA v2](https://developers.google.com/recaptcha/docs/display))
- **v2 invisible** ([Invisible reCAPTCHA](https://developers.google.com/recaptcha/docs/invisible))

Get your key first!
-------------------

[](#get-your-key-first)

First of all you have to create your own API keys [here](https://www.google.com/recaptcha/admin)

Follow the instructions and at the end of the process you will find **Site key** and **Secret key**. Keep them close..you will need soon!

Requirements
------------

[](#requirements)

DependencyVersionPHP^8.2Laravel^11.0, ^12.0, ^13.0Installation
------------

[](#installation)

You can install the package via composer:

```
composer require blissjaspis/laravel-recaptcha
```

The service provider will be automatically registered.

You can publish the config file with:

```
php artisan vendor:publish --provider="BlissJaspis\ReCaptcha\ReCaptchaServiceProvider"
```

This will create a `config/recaptcha.php` file in your app that you can modify to set your configuration.

### Set your API Keys

[](#set-your-api-keys)

Open `.env` file and set `RECAPTCHA_SITE_KEY` and `RECAPTCHA_SECRET_KEY`:

```
# in your .env file
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=
RECAPTCHA_SKIP_IP=
```

`RECAPTCHA_SKIP_IP` (not required, CSV format) allows you to add a list of IP/CIDR to whitelist.

### Configuration

[](#configuration)

Open `config/recaptcha.php` configuration file to set your default `version` and other options. All options are documented inside the configuration file.

> **!!! IMPORTANT !!!** Every time you change your configuration, run `php artisan config:cache` to apply the changes.

Usage
-----

[](#usage)

### Customize error message

[](#customize-error-message)

For v2 and invisible reCAPTCHA, you can customize the validation error message. Add your message to the `resources/lang/[LANG]/validation.php` file:

```
return [
    //...
    'recaptcha' => 'The reCAPTCHA validation failed. Please try again.',
];
```

### ReCAPTCHA v2 Checkbox

[](#recaptcha-v2-checkbox)

1. **Embed in Blade**

    Insert `{!! htmlScriptTagJsApi() !!}` helper before closing `` tag in your template.

    ```

            ...
            {!! htmlScriptTagJsApi() !!}

        ...

    ```

    Inside your form, use the `{!! htmlFormSnippet() !!}` helper.

    ```

        @csrf
        ...
        {!! htmlFormSnippet() !!}
        Submit

    ```
2. **Verify submitted data**

    Add `recaptcha` to your validation rules:

    ```
    $validator = Validator::make(request()->all(), [
        'g-recaptcha-response' => 'recaptcha',
        // OR
        recaptchaFieldName() => recaptchaRuleName()
    ]);
    ```

### ReCAPTCHA v2 Invisible

[](#recaptcha-v2-invisible)

1. **Embed in Blade**

    Insert `{!! htmlScriptTagJsApi() !!}` before closing `` tag. The form requires an ID that matches the one in your `config/recaptcha.php`. By default, it's `blissjaspis-recaptcha-invisible-form`. You can get it with `getFormId()`.

    Use the `{!! htmlFormButton('Submit') !!}` helper to generate the submit button.

    ```

      @csrf
      ...
      {!! htmlFormButton('Submit', ['class' => 'btn btn-primary']) !!}

    ```
2. **Verify submitted data**

    The validation rule is the same as for v2 checkbox.

### ReCAPTCHA v3

[](#recaptcha-v3)

1. **Embed in Blade**

    Insert `{!! htmlScriptTagJsApi() !!}` before closing `` tag. You need to pass some configuration.

    ```

            ...

            {!! htmlScriptTagJsApi([
                'action' => 'homepage',
                'callback_then' => 'callbackThen',
                'callback_catch' => 'callbackCatch'
            ]) !!}

        ...

    ```

    The configuration keys are:

    - `action`: The action name for reCAPTCHA v3.
    - `callback_then`: Javascript function to call on success.
    - `callback_catch`: Javascript function to call on error.
    - `custom_validation`: Your own Javascript validation function.
2. **Handling validation**

    The package provides a built-in Javascript validation system that makes an AJAX call to the validation route. You can define `callback_then` and `callback_catch` functions to handle the response.

    ```

        function callbackThen(response) {
            // read HTTP status
            console.log(response.status);

            // read Promise object
            response.json().then(function(data){
                console.log(data);
            });
        }
        function callbackCatch(error) {
            console.error('Error:', error)
        }

    ```

    Alternatively, you can provide a `custom_validation` function to handle the token yourself.

    ```

        function myCustomValidation(token) {
            // Your custom validation logic here.
        }

    ```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance83

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96% 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.

###  Release Activity

Cadence

Every ~265 days

Total

2

Last Release

89d ago

Major Versions

v1.0.0 → v2.0.02026-03-30

PHP version history (2 changes)v1.0.0PHP ^8.1

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8768022?v=4)[jaspis](/maintainers/jaspis)[@jaspis](https://github.com/jaspis)

---

Top Contributors

[![biscolab](https://avatars.githubusercontent.com/u/9263090?v=4)](https://github.com/biscolab "biscolab (267 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![blissjaspis](https://avatars.githubusercontent.com/u/19877298?v=4)](https://github.com/blissjaspis "blissjaspis (2 commits)")[![paulredmond](https://avatars.githubusercontent.com/u/177773?v=4)](https://github.com/paulredmond "paulredmond (1 commits)")[![aaronsaray](https://avatars.githubusercontent.com/u/956888?v=4)](https://github.com/aaronsaray "aaronsaray (1 commits)")[![rafaelyanagui](https://avatars.githubusercontent.com/u/6343584?v=4)](https://github.com/rafaelyanagui "rafaelyanagui (1 commits)")[![dispercity](https://avatars.githubusercontent.com/u/69723412?v=4)](https://github.com/dispercity "dispercity (1 commits)")[![matthiasgrube](https://avatars.githubusercontent.com/u/45481056?v=4)](https://github.com/matthiasgrube "matthiasgrube (1 commits)")

---

Tags

laravelvalidationrecaptchacaptcha

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[galahad/laravel-addressing

Laravel package providing addressing functionality

69328.0k](/packages/galahad-laravel-addressing)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)

PHPackages © 2026

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