vaail / no-captcha by vaail

No CAPTCHA reCAPTCHA For Laravel.
179
1
1
Package Data
Maintainer Username: vaail
Maintainer Contact: dzotcrew@gmail.com (vaail)
Package Create Date: 2016-03-02
Package Last Update: 2017-08-03
Language: PHP
License: MIT
Last Refreshed: 2024-04-23 03:00:23
Package Statistics
Total Downloads: 179
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

No CAPTCHA reCAPTCHA

recaptcha_anchor 2x

Installation

Add the following line to the require section of composer.json:

{
    "require": {
        "vaail/no-captcha": "1.*"
    }
}

Run composer update.

Laravel 5

Setup

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

'Vaail\NoCaptcha\NoCaptchaServiceProvider',

Configuration

Add NOCAPTCHA_SECRET and NOCAPTCHA_SITEKEY in .env file:

NOCAPTCHA_SECRET=[secret-key]
NOCAPTCHA_SITEKEY=[site-key]

Usage

Display reCAPTCHA
{!! app('captcha')->display(); !!}
Validation

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


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

Without Laravel

Checkout example below:

<?php

require_once "vendor/autoload.php";

$secret  = '';
$sitekey = '';
$captcha = new \Vaail\NoCaptcha\NoCaptcha($secret, $sitekey);

if ( ! empty($_POST)) {
    var_dump($captcha->verifyResponse($_POST['g-recaptcha-response']));
    exit();
}

?>

<form action="?" method="POST">
    <?php echo $captcha->display(); ?>
    <button type="submit">Submit</button>
</form>

Contribute

https://github.com/vaail/no-captcha/pulls