los / losrecaptcha
ZF2 module for integration with new ReCaptcha service form Google
Requires
- php: ^7.1
- laminas/laminas-captcha: ^2.7
- laminas/laminas-form: ^2.11
Requires (Dev)
- laminas/laminas-coding-standard: ^1.0
- laminas/laminas-http: ^2.7
- phpstan/phpstan: ^0.9.2
- squizlabs/php_codesniffer: ^2.7
Suggests
- los/losbase: los/losbase for some abstract classes to speed development
- los/loslog: los/loslog for logging
- los/losui: los/losui for twitter bootstrap 3 styling, jquery, chosen and other libraries
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-04 18:17:40 UTC
README
Warning
Archived
This Zend Form reCAPTCHA v2 integration is no longer maintained and will receive no further releases. Use the current SDK and integration guidance from your chosen bot-protection provider for new applications.
PHP module for using the ReCaptcha v2 system from Google
https://www.google.com/recaptcha/intro/index.html
Zend Form
To use with Zend\Form, just initialize like the default ReCaptcha element:
$this->add([ 'name' => 'captcha', 'type' => 'captcha', 'options' => [ 'captcha' => new LosReCaptcha\Captcha\ReCaptcha([ 'site_key' => $siteKey, 'secret_key' => $siteSecret, ]), ], ]);
For Invisible ReCaptcha:
// ... $this->add([ 'name' => 'captcha', 'type' => 'captcha', 'options' => [ 'captcha' => new \LosReCaptcha\Captcha\Invisible([ 'site_key' => $siteKey, 'secret_key' => $siteSecret, 'callback' => 'captchaSubmit', // Callback to submit the form 'button_id' => 'submit-button', // Button id to submit the form ]), ], ]); // ... $this->add([ 'name' => 'submit-button', 'type' => \Zend\Form\Element\Button::class, 'options' => [ 'label' => _('Log In'), ], 'attributes' => [ 'id' => 'submit-button', 'class' => 'btn btn-block btn-primary', 'value' => _('Log In'), ], ]);
In the view for Invisible ReCaptcha:
function captchaSubmit() {
// Any js code, eg. fields validation
document.getElementById("login").submit();
}
For Zend Expressive, you can inject the configuration with the ConfigProvider inside your config/config.php:
<?php // ... $aggregator = new ConfigAggregator([ // ... \LosReCaptcha\ConfigProvider::class, // ... ], $cacheConfig['config_cache_path']); return $aggregator->getMergedConfig();