davmixcool/google-recaptcha

Google Recaptcha Package For PHP front and backend.

0.8.2 2018-12-24 01:19 UTC

This package is auto-updated.

Last update: 2024-04-12 03:48:07 UTC


README

A PHP package which supports both back-end and front-end of Google recaptcha v2.

Requirements

  • PHP 5.5 and above

Steps:

Installation

Composer

Run the following command to include this package via Composer

composer require davmixcool/google-recaptcha

Usage

Simple to use.

use Davmixcool\GoogleRecaptcha;
	
	//include the recaptcha configurations globally
	$googleRecaptcha = new GoogleRecaptcha([
		'secret_key' => 'Your secret key',
		'site_key' => 'Your site key',
		'theme' => 'light'
	]);

	//Place the renderJs before the closing body tag.
	$googleRecaptcha->renderJs();

	//Place the renderCaptcha where you want to display the captcha.
	$googleRecaptcha->renderCaptcha();

	// Check if captcha was passed successfully 
	if ($googleRecaptcha->check()) {
	    // Perform success action

	} else {
	    // Throw an error if catcha was not solved successfully
	}

Maintainers

This package is maintained by David Oti and you!

License

This package is licensed under the MIT license.