los/losrecaptcha
最新稳定版本:2.2.0
Composer 安装命令:
composer require los/losrecaptcha
包简介
ZF2 module for integration with new ReCaptcha service form Google
README 文档
README
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();
统计信息
- 总下载量: 32.71k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-03-18