PHPackages                             webmavens/auto-google-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. webmavens/auto-google-recaptcha

ActiveLibrary[Security](/categories/security)

webmavens/auto-google-recaptcha
===============================

Globally add Google reCAPTCHA to all the forms and validate it.

0.0.1(10mo ago)13MITPHPPHP &gt;=5.5.5

Since Sep 2Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/webmavens/auto-google-recaptcha)[ Packagist](https://packagist.org/packages/webmavens/auto-google-recaptcha)[ RSS](/packages/webmavens-auto-google-recaptcha/feed)WikiDiscussions master Synced today

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

Auto Google reCAPTCHA
=====================

[](#auto-google-recaptcha)

A package to add **Google reCAPTCHA v2 Invisible / v3** protection to your entire application forms. Supports **Laravel (all versions)** and **Core PHP projects**.

---

🚀 Installation
--------------

[](#-installation)

Require the package via Composer:

```
composer require webmavens/auto-google-recaptcha
```

---

⚙️ Laravel Setup
----------------

[](#️-laravel-setup)

### Laravel 11 and above

[](#laravel-11-and-above)

No manual registration needed — **Service Provider and Facade are auto-discovered**.

#### Middleware

[](#middleware)

In **Laravel 11+**, add the middleware to the `web` group in your `bootstrap/app.php` file:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->group('web', [
        \WebMavens\AutoGoogleRecaptcha\Laravel\Middleware\VerifyRecaptcha::class,
    ]);
})
```

---

### Laravel 10 and below

[](#laravel-10-and-below)

For older Laravel versions, you need to register service provider, facade, and middleware manually.

#### Service Provider

[](#service-provider)

Add to `config/app.php` providers array:

```
'providers' => [
    // ...
    WebMavens\AutoGoogleRecaptcha\AutoGoogleRecaptchaServiceProvider::class,
],
```

#### Facade

[](#facade)

Add to `config/app.php` aliases array:

```
'aliases' => [
    // ...
    'AutoReCaptcha' => WebMavens\AutoGoogleRecaptcha\Laravel\Facades\AutoGoogleRecaptcha::class,
],
```

#### Middleware

[](#middleware-1)

Add to `app/Http/Kernel.php` in the `web` middleware group:

```
protected $middlewareGroups = [
    'web' => [
        // ...
        \WebMavens\AutoGoogleRecaptcha\Laravel\Middleware\VerifyRecaptcha::class,
    ],
];
```

---

### Publish Config &amp; Assets

[](#publish-config--assets)

For all Laravel versions, publish the config and JS file:

```
php artisan vendor:publish --provider="WebMavens\AutoGoogleRecaptcha\Laravel\AutoGoogleRecaptchaServiceProvider"
```

This publishes:

- Config → `config/auto-google-recaptcha.php`
- JS → `public/vendor/auto-google-recaptcha/auto-recaptcha.js`

**Note:** You can then make changes into javascript or config file based on your needs. Also you can add the javascript validation and specify when you want to load the reCAPTCHA by adding or modifying javascript.

---

### Environment Variables

[](#environment-variables)

Get the sitekey and secret from [Google Recaptcha](https://www.google.com/u/2/recaptcha/admin/create). Add the following to your `.env` file,

```
NOCAPTCHA_SITEKEY=your-site-key
NOCAPTCHA_SECRET=your-secret-key
NOCAPTCHA_ENABLE=true
```

---

### Render JS

[](#render-js)

Add this to your main layout (e.g. `layouts/app.blade.php`):

```
{!! AutoReCaptcha::renderJs() !!}
```

This ensures reCAPTCHA script is injected globally.

---

⚙️ Core PHP Setup
-----------------

[](#️-core-php-setup)

You can also use this package in plain PHP projects.

1. Copy `Middleware.php` from the package `src/` directory to your php project's root directory.
2. In your `index.php` (or main entry file), include it as this (`Middleware.php` file handles validations for each requests based on the configuration.):

```

    reCAPTCHA Test

    Test reCAPTCHA Form

        Submit

```

3. Add your config in `config/auto-google-recaptcha.php` (same format as Laravel).

---

🔧 Config
--------

[](#-config)

The published config file looks like this:

```
return [
    'secret' => env('NOCAPTCHA_SECRET', ''),
    'sitekey' => env('NOCAPTCHA_SITEKEY', ''),
    'options' => [
        'timeout' => 30,

        // Methods requiring captcha
        'allowed_methods' => [
            'POST',
            'PUT',
            'DELETE'
        ],

        // Routes to exclude from captcha
        // Note: For Laravel, Add route name with wildcards (eg. post.create, post.edit, post.*)
        // Note: For PHP, Add url paths to exclude with wildcards (eg. /post/create, /post/edit, *post*)
        'excluded_routes' => [
            'admin.*' // supports wildcards
        ],

        // Enable/disable globally
        'enable' => env('NOCAPTCHA_ENABLE', true),
    ],
];
```

Other Config &amp; Notes
------------------------

[](#other-config--notes)

- For core PHP project replace env() function with static values if you haven't downloaded env package, else it will throw function error.
- If you don't want to add the reCAPTCHA to any form in frontend then add `data-no-captcha` attribute to form tag and it will exclude that form from rendering the reCAPTCHA. You can use this feature with `allowed_methods` config to completely exclude any form from reCAPTCHA validation.

---

### Ajax Config

[](#ajax-config)

- This prebuilt JS also add captcha to all ajax requests.
- If you don't want to add the reCAPTCHA to any ajax request in frontend then add `disableCaptcha: true` attribute to ajax options and it will exclude that request from adding the reCAPTCHA. You can use this feature with `allowed_methods` config to completely exclude any ajax request from reCAPTCHA validation.

---

### Manual reCAPTCHA

[](#manual-recaptcha)

- You can also add google reCAPTCHA to any form manually if needed:

1. Create a div with data-size="invisible".

```

```

2. Call grecaptcha.execute from a javascript method.

```
grecaptcha.execute();
```

Read Full Documentation for reCAPTCHA v2 [here](https://developers.google.com/recaptcha/docs/invisible) and for reCAPTCHA v3 [here](https://developers.google.com/recaptcha/docs/v3)

---

🛡️ Behavior
-----------

[](#️-behavior)

- Captcha enforced only on configured HTTP methods (default: `POST`, `PUT`, `DELETE`)
- Skips validation on excluded routes (`admin.*`, etc.)
- On failure → returns **HTTP 403**
- Validation uses Google reCAPTCHA v2 Invisible or v3 API

---

✨ Features
----------

[](#-features)

- Works with Laravel **11+** (auto-discovery) and older versions
- Works with **Core PHP** projects
- Global middleware validation
- Configurable methods and route exclusions
- Supports reCAPTCHA v2 Invisible &amp; v3
- Easy asset publishing

---

📄 License
---------

[](#-license)

MIT License © [Web Mavens](https://github.com/webmavens)

---

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance56

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

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

Unknown

Total

1

Last Release

304d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/66283568?v=4)[Web Mavens](/maintainers/webmavens)[@webmavens](https://github.com/webmavens)

---

Top Contributors

[![yash-webmavens](https://avatars.githubusercontent.com/u/174307111?v=4)](https://github.com/yash-webmavens "yash-webmavens (11 commits)")[![sawan-webmavens](https://avatars.githubusercontent.com/u/456840?v=4)](https://github.com/sawan-webmavens "sawan-webmavens (6 commits)")

### Embed Badge

![Health badge](/badges/webmavens-auto-google-recaptcha/health.svg)

```
[![Health](https://phpackages.com/badges/webmavens-auto-google-recaptcha/health.svg)](https://phpackages.com/packages/webmavens-auto-google-recaptcha)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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