reCAPTCHA Plugin for CakePHP 3.x Version 3.0
Allows for easy use of recatpcha api from Google.
- Updated to work with CakePHP 3.0
- Switched to use recaptcha-php-5 library instead of the function based library.
- Updated to work with CakePHP 2.5
To include the Recaptcha plugin in your project, add the following code to your app/Config/bootstrap.php file:
CakePlugin::load('Recaptcha');
In your Controller:
public $helpers = array(
'Form',
'Recaptcha.Recaptcha'
);
public $components = array(
'Recaptcha.Recaptcha'
);
To display the reCapthca widget on your form in your View:
$this->Captcha->showSimple(array $optional_settings);
Multiple recaptcha on a same page
$this->Captcha->init(['field1', 'field2']);
$this->Captcha->showMultiple('field1');
$this->Captcha->showMultiple('field2');
Then to verify the reCAPTCHA in your Controller:
if (!$this->Captcha->validate()) {
// Add whatever code you need to use to show an error.
}
For a full description of the customization options, please visit the reCAPTCHA customization page. Below are the three most common settings. These can be set in the helper settings directly, or passed as an array when calling CaptchaHelper::show().
- theme -- red - The default theme. -- white -- blackglass -- clean -- custom See the documentation.
- lang -- en - English (the default) -- nl - Dutch -- fr - French -- de - German -- pt - Portuguese -- ru - Russian -- es - Spanish -- tr - Turkish
- tabindex - Sets a tabindex for the reCAPTCHA text box. If other elements in the form use a tabindex, this should be set so that navigation is easier for the user. The default is 0.
This plugin is released under the BSD License. You can find a copy of this licenese in LICENSE.md.