dapikk / ko7-recaptcha
Simple wrapper for Ko7even MVC for Google's reCAPTCHA library
1.1.1
2025-02-18 13:28 UTC
Requires
- php: >=7.4
- google/recaptcha: ^1.3
Requires (Dev)
- phpunit/phpunit: >=7.5.2
README
Simple wrapper for Google's reCAPTCHA library
A single class that allows you to add Google reCAPTCHA to your Ko7 forms. Code is very simple.
Installation
Direct download: Download the ZIP file and extract into your project. OR
composer require dapikk/ko7-recaptcha
Requires
- PHP => 7.4
- Ko7even => 3.3.8
- Google/reCaptcha => 1.3.0
Usage
- First obtain the appropriate keys for the type of reCAPTCHA you wish to integrate for v2 at https://www.google.com/recaptcha/admin
- Copy config from MODPATH/recaptcha/config/recaptcha.php to APPATH/config/recaptcha.php
- Make needed changes to configuration array!
- Activate recaptcha module in bootstrap!
To activate module:
Kohana::modules([ ... 'recaptcha' => MODPATH . 'recaptcha', ... ]);
To initialize reCaptcha check form on Your page:
<?php echo Recaptcha::instance()->get_html(); ?>
Or if multiple captchas are needed on same page then to provide some unique ID with request:
<?php echo Recaptcha::instance()->get_html('uniqueid12345'); ?>
To check verification from POST:
<?php $x = Recaptcha::instance()->check($_POST['g-recaptcha-response']); if($x == FALSE){ echo __('Please resubmit Google reCaptcha check!'); }else{ echo __('Recaptcha check succeeded!!!!'); } ?>
Config
recaptcha.php
return array( 'public_key' => 'YOUR GOOGLE RECAPTCHA SITE KEY', 'private_key' => 'YOUR GOOGLE RECAPTCHA SECRET KEY', 'version' => 'v2', //version required - recommended is to use v2 as it is more secure!!! 'rscore' => NULL, //Minimum score for safe actions, defaults to 0.5 and up - needed for Google reCaptcha version v3 'theme' => 'light', 'dlang' => 'en', 'dsize' => 'normal', );