mmilidoni/grecaptcha

Google Recaptcha Utilities

dev-master 2017-07-26 23:33 UTC

This package is not auto-updated.

Last update: 2025-09-14 08:46:09 UTC


README

This package allows an easily management of Google Recaptcha on your Laravel projects.

Prerequisites

Google Recaptcha V2 site key and secret key available on ReCAPTCHA website

Installation

composer require "mmilidoni/grecaptcha:dev-master"

Configuration

Add your Recaptcha site key and secret key on config/services.php

"grecaptcha" => [
        "secret" => "*****",
        "sitekey" => "****",
    ],

View

Insert the following line on your HTML header

<script src='https://www.google.com/recaptcha/api.js'></script>

Insert the following line on your HTML form

<div class="g-recaptcha" data-sitekey="{{ config("services.grecaptcha.sitekey") }}"></div>

Controller

use Mmilidoni\Grecaptcha\Grecaptcha;

class Example {
	public function store(\Illuminate\Http\Request $request) {
	  $a = new Grecaptcha;
	  if ($a->check($request)) {
    	// Recaptcha OK
	  } else {
    	// Recaptcha KO
	  }
	}
}