PHPackages                             los/losrecaptcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. los/losrecaptcha

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

los/losrecaptcha
================

ZF2 module for integration with new ReCaptcha service form Google

2.2.0(6y ago)333.4k—6.3%4[1 issues](https://github.com/Lansoweb/LosReCaptcha/issues)BSD-3-ClausePHPPHP ^7.1

Since Mar 18Pushed 6y ago3 watchersCompare

[ Source](https://github.com/Lansoweb/LosReCaptcha)[ Packagist](https://packagist.org/packages/los/losrecaptcha)[ Docs](http://github.com/Lansoweb/LosReCaptcha)[ RSS](/packages/los-losrecaptcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (12)Used By (0)

LosReCaptcha
============

[](#losrecaptcha)

PHP module for using the ReCaptcha v2 system from Google

Zend Form
---------

[](#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](https://developers.google.com/recaptcha/docs/invisible):

```
// ...
$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:

```
