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

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

chitranu/google-recaptcha
=========================

Easily validate recaptcha responses in Laravel. A handy validation rule for validating the reCAPTCHA token in the form requests.

1.2.3(6y ago)62.6k3MITPHPPHP ^7.0

Since Mar 15Pushed 5y ago2 watchersCompare

[ Source](https://github.com/chitranu/google-recaptcha)[ Packagist](https://packagist.org/packages/chitranu/google-recaptcha)[ Docs](https://github.com/chitranu/google-recaptcha)[ RSS](/packages/chitranu-google-recaptcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (4)Versions (10)Used By (0)

Google reCAPTCHA validator for Laravel
======================================

[](#google-recaptcha-validator-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/055f97140f69a2a9a96b235dd356b1ec860cfe8a9d9887dbf395f278ededd6fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368697472616e752f676f6f676c652d7265636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chitranu/google-recaptcha)[![Total Downloads](https://camo.githubusercontent.com/993bb7ec729c7835d399809b5e442b47c82cab931e685a2dcaecbebb51fb313e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368697472616e752f676f6f676c652d7265636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chitranu/google-recaptcha)

This package is a wrapper around [Google's reCAPTCHA PHP client library](https://github.com/google/recaptcha). It provides a handy validation rule `recaptcha`, which can be used to validate the reCAPTCHA token in the form requests.

You can use this package with any of reCAPTCHA types:

- Google reCAPTCHA v2
- Google reCAPTCHA v3

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

[](#installation)

You can install the package via composer:

```
composer require chitranu/google-recaptcha
```

Usage
-----

[](#usage)

Get Google reCAPTCHA secret key for your application from  and place it inside `.env` file at the root like this.

```
GOOGLE_RECAPTCHA_SECRETKEY=YOUR_RECAPTCHA_SECRET_KEY
```

After setting secret key, head over to your request validator, and add a field with rule the `recaptcha` like below to validate the token received in the form request.

```
$request->validate([
    '...' // other fields
    'recaptcha-token' => 'required|recaptcha'
]);
```

### Setting score threshold

[](#setting-score-threshold)

If you are getting a lot of spam submissions, you can take advantage of setting the score threshold while specifying the validation rule by setting a value between `0.1 - 1.0`. Read more about score threshold here: [https://developers.google.com/recaptcha/docs/v3#interpreting\_the\_score](https://developers.google.com/recaptcha/docs/v3#interpreting_the_score)

```
$request->validate([
    '...' // other fields
    'recaptcha-token' => 'required|recaptcha:0.5' // Specify threshhold
]);
```

Examples
--------

[](#examples)

### Using in frontend (vue-recaptcha-v3 plugin)

[](#using-in-frontend-vue-recaptcha-v3-plugin)

This package is intended to use with [vue-recaptcha-v3](https://github.com/AurityLab/vue-recaptcha-v3) npm plugin. You can use it by creating a Vue form component using `vue-recaptcha-v3` plugin shown below.

Register your site key with the `vue-recaptcha-v3` plugin:

```
import Vue from "vue";
import { VueReCaptcha } from "vue-recaptcha-v3";

Vue.use(VueReCaptcha, { siteKey: "YOUR_GOOGLE_SITE_KEY" });
```

Create a Vue component for the form and submit reCAPTCHA token using form like this:

```

    Submit

export default {
  methods: {
    async onFormSubmit() {
      // Wait until recaptcha has been loaded.
      await this.$recaptchaLoaded();

      // Execute reCAPTCHA with action "login".
      const token = await this.$recaptcha("login");

      // Prepare form data
      let formData = new FormData(this.$refs.contactform);

      // Appended token in formData
      formData.append("recaptcha-token", token);

      // Make an ajax request to your Laravel endpoint.
      axios.post("/your-form-endpoint", formData).then(
        (response) => {
          // handle response
        },
        (error) => {
          // handle errors
        }
      );
    },
  },
};

```

### Using in frontend (vue-recaptcha plugin)

[](#using-in-frontend-vue-recaptcha-plugin)

If you are using [vue-recaptcha](https://github.com/DanSnow/vue-recaptcha) plugin (older version), you can still use it by creating a vue form component shown below:

```

    Submit

import VueRecaptcha from "vue-recaptcha";

export default {
  components: {
    VueRecaptcha,
  },
  computed: {
    sitekey() {
      return "YOUR_GOOGLE_RECAPTHCA_SITE_KEY";
    },
  },
  methods: {
    onFormSubmit() {
      this.$refs.recaptcha.execute();
    },
    onCaptchaVerified(token) {
      // Prepare form data
      const formData = new FormData(this.$refs.contactform);

      // Appended token in formData
      formData.append("recaptcha-token", token);

      // Make an ajax request to your Laravel endpoint.
      axios.post("/your-form-endpoint", formData).then(
        (response) => {
          // handle response
        },
        (error) => {
          // handle errors
        }
      );
    },
    resetCaptcha() {
      this.$refs.recaptcha.reset();
    },
  },
};

```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email `swapnil@chitranu.com` instead of using the issue tracker.

Credits
-------

[](#credits)

- [Swapnil Bhavsar](https://github.com/iamswap)
- [Rajesh Dewle](https://github.com/rajeshdewle)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95% 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 ~4 days

Total

9

Last Release

2213d ago

PHP version history (2 changes)1.0.0PHP ^7.1

1.2.1PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/225879651394743b0f5bc28569d70a6d20df80fdf2b37351ea4f367105a051b6?d=identicon)[chitranu](/maintainers/chitranu)

---

Top Contributors

[![IamSwap](https://avatars.githubusercontent.com/u/5309384?v=4)](https://github.com/IamSwap "IamSwap (19 commits)")[![rajeshdewle](https://avatars.githubusercontent.com/u/31735480?v=4)](https://github.com/rajeshdewle "rajeshdewle (1 commits)")

---

Tags

laravelrecaptchaGoogle ReCaptchachitranu

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)[karser/karser-recaptcha3-bundle

Google ReCAPTCHA v3 for Symfony

1862.4M7](/packages/karser-karser-recaptcha3-bundle)

PHPackages © 2026

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