LaravelPackages.net
Acme Inc.
Toggle sidebar
daikazu/laravel-recaptcha

reCAPTCHA v2 and Invisible reCAPTCHA for laravel

563
0
v0.0.5
About daikazu/laravel-recaptcha

daikazu/laravel-recaptcha is a Laravel package for recaptcha v2 and invisible recaptcha for laravel. It currently has 0 GitHub stars and 563 downloads on Packagist (latest version v0.0.5). Install it with composer require daikazu/laravel-recaptcha. Discover more Laravel packages by daikazu or browse all Laravel packages to compare alternatives.

Last updated

Laravel reCAPTCHA

reCAPTCHA v2 and Invisible reCAPTCHA for Laravel

Easily add Google's V2 and Invisable reCaptcha to your forms;

This code is borrowed heavily from anhskohbo/no-captcha

Installation

composer require daikazu/laravel-recaptcha

Setup

NOTE This package supports Laravel 5.5 auto-discovery, so you can skip the setup if you are using 5.5 and above.

LARAVEL 5

Configuration

Public Config File recaptcha.php

php artisan vendor:publish --provider="Daikazu\LaravelRecaptcha\ReCaptchaServiceProvider"

Add your RECAPTCHA_SECRET and RECAPTCHA_SITEKEY into your .env file:

RECAPTCHA_SECRET=secret-key RECAPTCHA_SITEKEY=site-key

(You can obtain them from here)

Usage

Initialize javascript source:

With default options :

 {!! ReCaptcha::renderJs() !!}

With language support or onloadCallback option :

 {!! ReCaptcha::renderJs('fr', true, 'recaptchaCallback') !!}

Display reCAPTCHA V2

{!! ReCaptcha::displayWidget() !!}

With custom attributes (theme, size, callback ...) :

{!! ReCaptcha::displayWidget(['data-theme' => 'dark']) !!}

Display Invisible reCAPTCHA button

{!! ReCaptcha::displayButton( 'Button Text', ['data-callback' => 'onFormSubmit', 'class' => 'button is-info']) !!}

Validation

Add 'g-recaptcha-response' => 'required|recaptcha' to to validation rules array;

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

Then check for reCAPTCHA errors in the form:

@if ($errors->has('g-recaptcha-response'))
    <span class="help-block">
        <strong>{{ $errors->first('g-recaptcha-response') }}</strong>
    </span>
@endif

Testing

Comming soon!

Star History Chart