承接 codeit/recaptcha2 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

codeit/recaptcha2

最新稳定版本:2.0

Composer 安装命令:

composer require codeit/recaptcha2

包简介

reCAPTCHA 2.0 ("NoCaptcha") Module for Zend Framework 2 and Zend Framework 3

README 文档

README

Build Status Coverage Status Scrutinizer Code Quality Packagist

Installation

Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.

php composer.phar require codeit/recaptcha2

Then add ReCaptcha2 to your config/application.config.php.

Usage

Basic Usage

use ReCaptcha2\Captcha\ReCaptcha2;
use Laminas\Form\Element;
use Laminas\Form\Form;

//...
$form->add([
    'name' => 'captcha',
    'type' => Element\Captcha::class,
    'options' => [
        'captcha' => [
            'class' => ReCaptcha2::class,
            'options' => [
                'siteKey' => '<siteKey>',
                'secretKey' => '<secretKey>',
            ],
        ],
    ],
]);

Advanced configuration

use ReCaptcha2\Captcha\NoCaptchaService;
use ReCaptcha2\Captcha\ReCaptcha2;
use Laminas\Form\Element;
use Laminas\Form\Form;
use Laminas\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 = Laminas\Http\Client
                            'options' => [
                                //Laminas\Http\Client configuration
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
]);

SSL Issue / Google SSL Certificate

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 Laminas\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,
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
]);

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2025-05-02