Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
php composer.phar require breyndotechse/recaptcha2
Then add ReCaptcha2
to your config/application.config.php
.
use ReCaptcha2\Captcha\ReCaptcha2;
use Zend\Form\Element;
use Zend\Form\Form;
//...
$form->add([
'name' => 'captcha',
'type' => Element\Captcha::class,
'options' => [
'captcha' => [
'class' => ReCaptcha2::class,
'options' => [
'siteKey' => '<siteKey>',
'secretKey' => '<secretKey>',
],
],
],
]);
use ReCaptcha2\Captcha\NoCaptchaService;
use ReCaptcha2\Captcha\ReCaptcha2;
use Zend\Form\Element;
use Zend\Form\Form;
use Zend\Http\Client;
//...
$form->add([
'name' => 'captcha',
'type' => Element\Captcha::class,
'options' => [
'captcha' => [
'class' => ReCaptcha2::class, // Required
'options' => [
// Required:
'siteKey' => '<siteKey>',
'secretKey' => '<secretKey>',
// Optional:
'service' => [
'class' => NoCaptchaService::class, //Default = ReCaptcha2\Captcha\NoCaptchaService
'options' => [
'httpClient' => [
'class' => Client::class, //Default = Zend\Http\Client
'options' => [
//Zend\Http\Client configuration
],
],
],
],
],
],
],
]);
PHP Warning: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Set the openssl.cafile configuration setting in your php.ini, .user.ini or .htaccess. You can find a bundle of CA certificates here: cURL CA Certificate Bundle. This module comes with a cacert.pem file containing the "Google Internet Authority G2" and the "GeoTrust Global CA" CA certificate.
Otherwise set the Zend\Http\Client
sslcafile
configuration key:
$form->add([
'name' => 'captcha',
'type' => Element\Captcha::class,
'options' => [
'captcha' => [
'class' => ReCaptcha2::class,
'options' => [
'siteKey' => '<siteKey>',
'secretKey' => '<secretKey>',
'service' => [
'options' => [
'httpClient' => [
'options' => [
'sslcafile' => ReCaptcha2\Captcha\NoCaptchaService::CACERT_PATH,
],
],
],
],
],
],
],
]);