PHPackages                             esyede/hidden-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. esyede/hidden-recaptcha

ActiveLibrary[Security](/categories/security)

esyede/hidden-recaptcha
=======================

Hidden reCAPTCHA For Laravel.

v1.0.0(1y ago)019MITPHPPHP ^7.4

Since Jul 15Pushed 1y ago1 watchersCompare

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

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

Laravel Hidden reCAPTCHA v3
===========================

[](#laravel-hidden-recaptcha-v3)

[![Packagist PHP Version](https://camo.githubusercontent.com/1a63a4594e04e907d4c22cbbb4fcb95235904a62b4ea7da83700b2daf125c054/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6573796564652f68696464656e2d7265636170746368613f7374796c653d666c61742d737175617265)](https://packagist.org/packages/esyede/hidden-recaptcha)[![Packagist Version](https://camo.githubusercontent.com/56acffd8e0ea061d09d4934cd3c4af2b15d7c17f7179227234ee3688f290ef3a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6573796564652f68696464656e2d7265636170746368613f7374796c653d666c61742d737175617265)](https://packagist.org/packages/esyede/hidden-recaptcha)

Support
-------

[](#support)

Laravel 8+, PHP `>=7.4`.

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

[](#installation)

```
composer require esyede/hidden-recaptcha

```

### Setup

[](#setup)

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

```
Esyede\HiddenReCaptcha\HiddenReCaptchaServiceProvider::class,

```

### Configuration

[](#configuration)

Adjust your `.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

```

> 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 \Esyede\HiddenReCaptcha\HiddenReCaptcha(
    $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:

```
