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

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

rowanfuchs/invisible-recaptcha
==============================

Invisible reCAPTCHA For Laravel.

1.0.1(1y ago)022[1 PRs](https://github.com/rowanfuchs/invisible-recaptcha/pulls)MITPHPPHP ^8.0 || ^8.3

Since Apr 5Pushed 1y agoCompare

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

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

Invisible reCAPTCHA
===================

[](#invisible-recaptcha)

[![php-badge](https://camo.githubusercontent.com/4cbdbfeca62402b9ca3d48503f2bf66fc9809569bcd6de47196d39fecff71e72/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e362d3838393242462e737667)](https://camo.githubusercontent.com/4cbdbfeca62402b9ca3d48503f2bf66fc9809569bcd6de47196d39fecff71e72/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e362d3838393242462e737667)[![packagist-badge](https://camo.githubusercontent.com/ec609b38d17d33e85509567d45ce1914a30e4b5dff54d7a092ea1dd6a203f383/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c626572746368742f696e76697369626c652d7265636170746368612e737667)](https://packagist.org/packages/albertcht/invisible-recaptcha)[![Total Downloads](https://camo.githubusercontent.com/db903cf0acc5c1bff1026e09556a834920227bf46f5cca9a9f906053d4a72d95/68747470733a2f2f706f7365722e707567782e6f72672f616c626572746368742f696e76697369626c652d7265636170746368612f646f776e6c6f616473)](https://packagist.org/packages/albertcht/invisible-recaptcha)[![travis-badge](https://camo.githubusercontent.com/8f278541e5cb6b53b2b5fb7aaf29aeccbb2b2bb90819e4781195ec2455b4803f/68747470733a2f2f6170692e7472617669732d63692e6f72672f616c626572746368742f696e76697369626c652d7265636170746368612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/albertcht/invisible-recaptcha)

[![invisible_recaptcha_demo](https://camo.githubusercontent.com/db912f64af2f54c24e06ad603639f6824ea73addffa3ceb3f6328913982d2cf5/687474703a2f2f692e696d6775722e636f6d2f31645a39584b6e2e706e67)](https://camo.githubusercontent.com/db912f64af2f54c24e06ad603639f6824ea73addffa3ceb3f6328913982d2cf5/687474703a2f2f692e696d6775722e636f6d2f31645a39584b6e2e706e67)

Why Invisible reCAPTCHA?
------------------------

[](#why-invisible-recaptcha)

Invisible reCAPTCHA is an improved version of reCAPTCHA v2(no captcha). In reCAPTCHA v2, users need to click the button: "I'm not a robot" to prove they are human. In invisible reCAPTCHA, there will be not embed a captcha box for users to click. It's totally invisible! Only the badge will show on the buttom of the page to hint users that your website is using this technology. (The badge could be hidden, but not suggested.)

Notice
------

[](#notice)

- The master branch doesn't support multi captchas feature, please use `multi-forms` branch if you need it. (**Most of the time you are misusing recaptcha when you try to put multiple captchas in one page.**)

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

[](#installation)

```
composer require albertcht/invisible-recaptcha

```

Laravel 5
---------

[](#laravel-5)

### Setup

[](#setup)

Add ServiceProvider to the providers array in `app/config/app.php`.

```
AlbertCht\InvisibleReCaptcha\InvisibleReCaptchaServiceProvider::class,

```

> It also supports package discovery for Laravel 5.5.

### Configuration

[](#configuration)

Before you set your config, remember to choose `invisible reCAPTCHA` while applying for keys. [![invisible_recaptcha_setting](https://camo.githubusercontent.com/bc407e52682a0ddbd067c418416e1307c9ddcd0ef16b51bbac6d414277dadbe4/687474703a2f2f692e696d6775722e636f6d2f7a49416c4b62592e6a7067)](https://camo.githubusercontent.com/bc407e52682a0ddbd067c418416e1307c9ddcd0ef16b51bbac6d414277dadbe4/687474703a2f2f692e696d6775722e636f6d2f7a49416c4b62592e6a7067)

Add `INVISIBLE_RECAPTCHA_SITEKEY`, `INVISIBLE_RECAPTCHA_SECRETKEY` to **.env** file.

```
// required
INVISIBLE_RECAPTCHA_SITEKEY={siteKey}
INVISIBLE_RECAPTCHA_SECRETKEY={secretKey}

// optional
INVISIBLE_RECAPTCHA_BADGEHIDE=false
INVISIBLE_RECAPTCHA_DATABADGE='bottomright'
INVISIBLE_RECAPTCHA_TIMEOUT=5
INVISIBLE_RECAPTCHA_DEBUG=false
INVISIBLE_RECAPTCHA_MIN_SCORE=0.5

```

> By default `INVISIBLE_RECAPTCHA_MIN_SCORE` is set to: `0.5` anything below that value is treated as spam, increase the score if you still experience spam

> There are three different captcha styles you can set: `bottomright`, `bottomleft`, `inline`

> If you set `INVISIBLE_RECAPTCHA_BADGEHIDE` to true, you can hide the badge logo.

> You can see the binding status of those catcha elements on browser console by setting `INVISIBLE_RECAPTCHA_DEBUG` as true.

### Usage

[](#usage)

Before you render the captcha, please keep those notices in mind:

- `render()` or `renderHTML()` function needs to be called within a form element.
- You have to ensure the `type` attribute of your submit button has to be `submit`.
- There can only be one submit button in your form.

##### Display reCAPTCHA in Your View

[](#display-recaptcha-in-your-view)

```
{!! app('captcha')->render() !!}

// or you can use this in blade
@captcha
```

With custom language support:

```
{!! app('captcha')->render('en') !!}

// or you can use this in blade
@captcha('en')
```

##### Usage with Javascript frameworks like VueJS:

[](#usage-with-javascript-frameworks-like-vuejs)

The `render()` process includes three distinct sections that can be rendered separately incase you're using the package with a framework like VueJS which throws console errors when `` tags are included in templates.

You can render the polyfill (do this somewhere like the head of your HTML:)

```
{!! app('captcha')->renderPolyfill() !!}
// Or with blade directive:
@captchaPolyfill
```

You can render the HTML using this following, this needs to be INSIDE your `` tag:

```
{!! app('captcha')->renderCaptchaHTML() !!}
// Or with blade directive:
@captchaHTML
```

And you can render the neccessary `` tags including the optional language support by using:

```
// The argument is optional.
{!! app('captcha')->renderFooterJS('en') !!}

// Or with blade directive:
@captchaScripts
// blade directive, with language support:
@captchaScripts('en')
```

##### Validation

[](#validation)

Add `'g-recaptcha-response' => 'required|captcha'` to rules array.

```
$validate = Validator::make(Input::all(), [
    'g-recaptcha-response' => 'required|captcha'
]);
```

CodeIgniter 3.x
---------------

[](#codeigniter-3x)

set in application/config/config.php :

```
$config['composer_autoload'] = TRUE;
```

add lines in application/config/config.php :

```
$config['recaptcha.sitekey'] = 'sitekey';
$config['recaptcha.secret'] = 'secretkey';
// optional
$config['recaptcha.options'] = [
    'hideBadge' => false,
    'dataBadge' => 'bottomright',
    'timeout' => 5,
    'debug' => false
];
```

In controller, use:

```
$data['captcha'] = new \AlbertCht\InvisibleReCaptcha\InvisibleReCaptcha(
    $this->config->item('recaptcha.sitekey'),
    $this->config->item('recaptcha.secret'),
    $this->config->item('recaptcha.options'),
);
```

In view, in your form:

```

```

Then back in your controller you can verify it:

```
$captcha->verifyResponse($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
```

Without Laravel or CodeIgniter
------------------------------

[](#without-laravel-or-codeigniter)

Checkout example below:

```
