dapikk/ko7-recaptcha

Simple wrapper for Ko7even MVC for Google's reCAPTCHA library

1.1.1 2025-02-18 13:28 UTC

This package is auto-updated.

Last update: 2025-07-18 15:02:07 UTC


README

PHP workflow Required minimum PHP Version Required minimum Ko7even Version Required minimum Google/reCaptcha Version Github Issues

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

  1. First obtain the appropriate keys for the type of reCAPTCHA you wish to integrate for v2 at https://www.google.com/recaptcha/admin
  2. Copy config from MODPATH/recaptcha/config/recaptcha.php to APPATH/config/recaptcha.php
  3. Make needed changes to configuration array!
  4. 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',
);