PHPackages                             timehunter/laravel-google-recaptcha-v2 - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. timehunter/laravel-google-recaptcha-v2

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

timehunter/laravel-google-recaptcha-v2
======================================

Laravel Package for google reCAPTCHA v2

v1.0.3(5y ago)1395.4k↓12.7%2[1 issues](https://github.com/RyanDaDeng/laravel-google-recaptcha-v2/issues)MITPHPPHP ^7.2.5 || ^8.0

Since Dec 28Pushed 5y ago2 watchersCompare

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

READMEChangelog (5)Dependencies (4)Versions (8)Used By (0)

Laravel Package for Google reCAPTCHA v2
=======================================

[](#laravel-package-for-google-recaptcha-v2)

[![Latest Version on Packagist](https://camo.githubusercontent.com/730d86eb2662b3d0f62e8c32a2d484ccabb9173aeb4b4b28f07ed54fd11c3935/68747470733a2f2f706f7365722e707567782e6f72672f74696d6568756e7465722f6c61726176656c2d676f6f676c652d7265636170746368612d76322f76657273696f6e)](https://packagist.org/packages/timehunter/laravel-google-recaptcha-v2)[![Total Downloads](https://camo.githubusercontent.com/41e484c3a941886ed0c57bbe2b2bd2a897cd803ee3caa102a7c112cb066f4ed8/68747470733a2f2f706f7365722e707567782e6f72672f74696d6568756e7465722f6c61726176656c2d676f6f676c652d7265636170746368612d76322f646f776e6c6f616473)](https://packagist.org/packages/timehunter/laravel-google-recaptcha-v2)[![Coverage Status](https://camo.githubusercontent.com/55428ec62ba80fd5f2aa42f805768d82dc75c3cf6987fdb9b8b240addc52c448/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f5279616e446144656e672f6c61726176656c2d676f6f676c652d7265636170746368612d76322f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/RyanDaDeng/laravel-google-recaptcha-v2?branch=master)[![Build](https://camo.githubusercontent.com/b1d0b184548d26a17b6bda5a0f4754ab3c4cdf19bcb2a9348eb48be2db5de73e/68747470733a2f2f7472617669732d63692e6f72672f5279616e446144656e672f6c61726176656c2d676f6f676c652d7265636170746368612d76322e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/RyanDaDeng/laravel-google-recaptcha-v2)

Welcome all tickets (features/questions/bugs/improvements), I will respond to all tickets within 48 hours.

This is a package for Google reCAPTCHA v2.

If you want to use v3, please go to:

DEMO
====

[](#demo)

Checkbox
--------

[](#checkbox)

[![](https://github.com/RyanDaDeng/aws-study-notes/raw/master/0DB7E6BA-15ED-45E7-AA12-3CEA05E1483E.png)](https://github.com/RyanDaDeng/aws-study-notes/blob/master/0DB7E6BA-15ED-45E7-AA12-3CEA05E1483E.png)

Invisible - hidden
------------------

[](#invisible---hidden)

[![](https://github.com/RyanDaDeng/aws-study-notes/raw/master/881545398213_.pic.jpg)](https://github.com/RyanDaDeng/aws-study-notes/blob/master/881545398213_.pic.jpg)

Invisible - Inline
------------------

[](#invisible---inline)

[![](https://github.com/RyanDaDeng/aws-study-notes/raw/master/891545398531_.pic.jpg)](https://github.com/RyanDaDeng/aws-study-notes/blob/master/891545398531_.pic.jpg)

Corner
------

[](#corner)

[![](https://github.com/RyanDaDeng/aws-study-notes/raw/master/901545398593_.pic.jpg)](https://github.com/RyanDaDeng/aws-study-notes/blob/master/901545398593_.pic.jpg)

Description
-----------

[](#description)

A Laravel package for Google reCAPTCHA v2.

If you want to make your own font-end template, you have full access to modify template file, so you can customise your own template by reading through Google official guide for either invisible badge or inline checkbox.

Features
--------

[](#features)

- Support invisible, corner and inline badge style
- Support multiple reCAPTCHA on the same page for different forms
- Support multiple actions to be placed on the same page
- Support custom implementation on config interface
- Support custom implementation on request method interface
- Support custom implementation on Template file

Requirement
-----------

[](#requirement)

This package requires the following dependencies:

- Laravel 5.x
- If you want to use Validation Class your Laravel version needs to be &gt;= 5.5
- php &gt; 5
- Please ensure that you have read basic information from Google reCAPTCHA v2.

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

[](#installation)

Via Composer

```
        $ composer require timehunter/laravel-google-recaptcha-v2 "~1.0.0" -vvv
```

If your Laravel framework version &lt;= 5.4, please register the service provider in your config file: /config/app.php, otherwise please skip it.

```
'providers'=[
    ....,
    TimeHunter\LaravelGoogleReCaptchaV2\Providers\GoogleReCaptchaV2ServiceProvider::class
]
```

And also

```
'aliases'=[
     ....,
     'GoogleReCaptchaV2'=> TimeHunter\LaravelGoogleReCaptchaV2\Facades\GoogleReCaptchaV2::class
 ]
```

If your Laravel framework version is &gt;= 5.5, just run the following command to publish config.

```
$ php artisan vendor:publish --provider="TimeHunter\LaravelGoogleReCaptchaV2\Providers\GoogleReCaptchaV2ServiceProvider" --tag=googlerecaptchav2.config
```

Optional: if you want to modify or customise your own template, you can publish a default view first, and change 'template' in config file:

```
$ php artisan vendor:publish --provider="TimeHunter\LaravelGoogleReCaptchaV2\Providers\GoogleReCaptchaV2ServiceProvider" --tag=googlerecaptchav2.views
```

After installation, you should see a googlerecaptchav2/template.blade under views folder and googlerecaptchav2.php in your app/config folder.

Basic Usage
-----------

[](#basic-usage)

#### Setting up your Google reCAPTCHA details in config file

[](#setting-up-your-google-recaptcha-details-in-config-file)

Please register all details on host\_name, site\_key, secret\_key and site\_verify\_url.

For more details please check comments in config file.

#### Display reCAPTCHA v2

[](#display-recaptcha-v2)

Note: for styling with reCAPTCHA v2 badge, the official site does not support it. You can still customise it on its div element if you want.

##### Blade

[](#blade)

Include div with an ID inside your form, e.g.

```

```

Include Template script in your bottom/header of your page, e.g.

```
 {!!  GoogleReCaptchaV2::render('form_id_1','form_id_2') !!}
```

##### Example Usage

[](#example-usage)

```
{{--if laravel version
    @csrf

    @csrf

{!!  GoogleReCaptchaV2::render('form_1_id','form_2_id') !!}
```

The backend request will receive a value for 'g-recaptcha-response', please take a look at Sample Use Case and Facade usage sections.

Badge Display
-------------

[](#badge-display)

Importance: you can always make your own template, just assign your template in config:

```
    [
        ...
        'template' => 'test.template' // if your template is located at resources/views/test/template
        ...
    ]
```

### Checkbox

[](#checkbox-1)

1. Go to config file, and set

```
    [
        ...
        'badge' => 'inline'
        ...
    ]
```

2. Badge will be displayed as checkbox format within the form.

### Invisible - inline

[](#invisible---inline-1)

1. Set size as invisible

```
    [
        ...
        'size' => 'invisible'
        ...
    ]
```

2. Set badge as inline or bottomright or bottomleft

```
    [
        ...
        'badge' => 'inline' // also support: bottomright,bottomleft
        ...
    ]
```

### Invisible - hidden

[](#invisible---hidden-1)

1. Set size as invisible

```
    [
        ...
        'size' => 'invisible'
        ...
    ]
```

2. Modify your div with style display:none
3. Refer to Google official site: , you need to include the following text:

```
   This site is protected by reCAPTCHA and the Google
       Privacy Policy and
       Terms of Service apply.
```

### Corner

[](#corner-1)

1. Set size as invisible

```
    [
        ...
        'size' => 'invisible'
        ...
    ]
```

2. Set badge as bottomright/bottomleft

```
    [
        ...
        'badge' => 'bottomright'
        ...
    ]
```

Validation Class (Only support Laravel &gt;= 5.5)
-------------------------------------------------

[](#validation-class-only-support-laravel--55)

You can use provided Validation object to verify your reCAPTCHA.

```
   use TimeHunter\LaravelGoogleReCaptchaV2\Validations\GoogleReCaptchaV2ValidationRule
   $rule = [
            'g-recaptcha-response' => [new GoogleReCaptchaV2ValidationRule()]
        ];
```

Facade Usage
------------

[](#facade-usage)

You can also directly use registered service by calling the following method.

- verifyResponse() which accepts the token value from your form. This return Google reCAPTCHA Response object.

```
   GoogleReCaptchaV2::verifyResponse($value, $ip=null);
```

Example Usage

```
   GoogleReCaptchaV2::verifyResponse($value,$ip)->getMessage();
   GoogleReCaptchaV2::verifyResponse($value)->isSuccess();
   GoogleReCaptchaV2::verifyResponse($value)->toArray();
```

```
   GoogleReCaptchaV2::verifyResponse($request->input('g-recaptcha-response'))->getMessage()
```

Sample Use Case
---------------

[](#sample-use-case)

1. Register your action in config, also enable score and set up your own site key and secret key:
2. Register two routes in web.php

```
Route::get('/index', 'ReCaptchaController@index');
Route::post('/verify', 'ReCaptchaController@verify');
```

3. Create two functions in controller:

```
    public function verify(Request $request)
    {
        dd(GoogleReCaptchaV2::verifyResponse($request->input('g-recaptcha-response'))->getMessage());
    }
    public function index(Request $request)
    {
        return view('index');
   }
```

4. Create your form in index.blade.php:

```
{{--if laravel version
    @csrf

    @csrf

{!!  GoogleReCaptchaV2::render('contact_us_id','signup_id') !!}
```

Advanced Usage
--------------

[](#advanced-usage)

#### Custom implementation on Template

[](#custom-implementation-on-template)

After publish views, a blade file created under googlerecaptchaV2, you can customise it and change template value in config file, e.g. if your template is saved in resources/views/test/template, you should put values as below:

```
    [
        ...
        'template' => 'test.template'
        ...
    ]
```

#### Custom implementation on Config

[](#custom-implementation-on-config)

For some users, they might store the config details in their own storage e.g database. You can create your own class and implement:

```
TimeHunter\LaravelGoogleReCaptchaV2\Interfaces\ReCaptchaConfigv2Interface

```

Remember to register it in your own service provider

```
     $this->app->bind(
                ReCaptchaConfigV2Interface::class,
                YourOwnCustomImplementation::class
            );
```

#### Custom implementation on Request method

[](#custom-implementation-on-request-method)

The package has two default options to verify: Guzzle and Curl, if you want to use your own request method, You can create your own class and implement

```
TimeHunter\LaravelGoogleReCaptchaV2\Interfaces\RequestClientInterface

```

Remember to register it in your own service provider

```
     $this->app->bind(
                RequestClientInterface::class,
                YourOwnCustomImplementation::class
            );
```

Contributers
------------

[](#contributers)

@markheramis

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 91.3% 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 ~201 days

Total

5

Last Release

1894d ago

Major Versions

0.1.1 → 1.0.02018-12-28

PHP version history (2 changes)0.1.1PHP &gt;=5.5

v1.0.3PHP ^7.2.5 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/957c97ad667a07032424eb2eb70cf2db7ad705c62926c23436f9ea4e32dca5b5?d=identicon)[timehunter](/maintainers/timehunter)

---

Top Contributors

[![RyanDaDeng](https://avatars.githubusercontent.com/u/37111049?v=4)](https://github.com/RyanDaDeng "RyanDaDeng (42 commits)")[![markheramis](https://avatars.githubusercontent.com/u/6801816?v=4)](https://github.com/markheramis "markheramis (4 commits)")

---

Tags

google-recaptchagoogle-recaptcha-v2googlerecaptchalaravel-google-recaptchalaravel-google-recaptcha-v2laravel-recaptchalaravel-recaptcha-v2recaptcharecaptcha-v2laravelrecaptchaGoogle ReCaptchaGoogleReCaptchaLaravel reCAPTCHAlaravel google recaptchareCAPTCHA V2google recaptcha v2laravel google recaptcha v2recaptcha v2 laravellaravel recaptcha v2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/timehunter-laravel-google-recaptcha-v2/health.svg)

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

###  Alternatives

[timehunter/laravel-google-recaptcha-v3

Laravel Package for google reCAPTCHA v3

2861.0M1](/packages/timehunter-laravel-google-recaptcha-v3)[anhskohbo/no-captcha

No CAPTCHA reCAPTCHA For Laravel.

1.8k8.5M33](/packages/anhskohbo-no-captcha)[josiasmontag/laravel-recaptchav3

Recaptcha V3 for Laravel package

2641.6M2](/packages/josiasmontag-laravel-recaptchav3)[rahul900day/laravel-captcha

Different types of Captcha implementation for Laravel Application.

10715.9k](/packages/rahul900day-laravel-captcha)[mostafaznv/recaptcha

Laravel package for Google Recaptcha v3

2127.5k](/packages/mostafaznv-recaptcha)[anam/captcha

reCAPTCHA and invisible reCAPTCHA for Laravel. reCAPTCHA protects your app against spam and bot.

2843.4k](/packages/anam-captcha)

PHPackages © 2026

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