2017 © Pedro Peláez
 

library recaptcha

Google Recaptcha for Laravel 5

image

waavi/recaptcha

Google Recaptcha for Laravel 5

  • Monday, November 28, 2016
  • by sildraug
  • Repository
  • 3 Watchers
  • 4 Stars
  • 3,355 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 7 Versions
  • 4 % Grown

The README.md

Google Recaptcha for Laravel 5

Latest Version on Packagist Software License Build Status Total Downloads, (*1)

Introduction

This is a reCAPTCHA Validator package for Laravel 5.1., (*2)

WAAVI is a web development studio based in Madrid, Spain. You can learn more about us at waavi.com, (*3)

Laravel compatibility

Laravel translation
5.1.x 1.0.x
5.2.x 1.0.4 and higher
5.3.x 1.0.5 and higher

Installation and Setup

Require through composer, (*4)

composer require waavi/recaptcha 1.0.x

Or manually edit your composer.json file:, (*5)

"require": {
    "waavi/recaptcha": "1.0.x"
}

In config/app.php, add the following entry to the end of the providers array:, (*6)

Waavi\ReCaptcha\ReCaptchaServiceProvider::class,

And the following alias:, (*7)

'ReCaptcha' => Waavi\ReCaptcha\Facades\ReCaptcha::class,

Publish the configuration file, the form view and the language entries:, (*8)

php artisan vendor:publish --provider="Waavi\ReCaptcha\ReCaptchaServiceProvider"

Enter your secret and site keys provided by Google in either your environment file (recommended) or the config file:, (*9)

RECAPTCHA_SITE_KEY=site_key
RECAPTCHA_SECRET_KEY=secret_key

A simple error message in english is provided when validation of a recaptcha fails. If you wish to customize it, add to your validation.php lang file the following entry:, (*10)

```php
'recaptcha' =>  'Your error message here',
```

Usage

Rendering the ReCaptcha form in your views

You may render the ReCaptcha widget in your blade forms by calling:, (*11)

{!! ReCaptcha::render() !!}

Or by including the provided view (if you choose to do this, the sitekey must be present as a parameter):, (*12)

@include('recaptcha::recaptcha', ['siteKey' => config('recaptcha.keys.site')])

You may also choose to customize the widget through the available options described in the official docs, (*13)

{!! ReCaptcha::render(['theme' => 'dark']) !!}

or

@include('recaptcha::recaptcha', ['siteKey' => config('recaptcha.keys.site'), 'options' => ['theme' => 'dark']])

Validating the ReCaptcha

There are two available options to validate the ReCaptcha. You may do so manually through the provided Facade:, (*14)

```php
$value = \Input::get('g-recaptcha-response');
$gResponse = \ReCaptcha::parseInput($value);

if ($gResponse->isSuccess()) {
    return true;
}
else {
    $errors = $gResponse->getErrorMessages();   // Returns an array of error messages in the form of errorCode => errorMessage
    var_dump($errors);
}
```

Or in a much more convinient way, through the provided Validator extension, adding to your rules array:, (*15)

```php
$rules = [
    /** Your rules ... **/
    'g-recaptcha-response' => 'recaptcha',
];
```

The Versions

28/11 2016

dev-master

9999999-dev

Google Recaptcha for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel recaptcha waavi

15/09 2016

1.0.5

1.0.5.0

Google Recaptcha for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel recaptcha waavi

16/03 2016

1.0.4

1.0.4.0

Google Recaptcha for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel recaptcha waavi

01/01 2016

1.0.3

1.0.3.0

Google Recaptcha for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel recaptcha waavi

01/01 2016

1.0.2

1.0.2.0

Google Recaptcha for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel recaptcha waavi

01/01 2016

1.0.1

1.0.1.0

Google Recaptcha for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel recaptcha waavi

01/01 2016

1.0

1.0.0.0

Google Recaptcha for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel recaptcha waavi