承接 xorock/zend-service-recaptcha-v2 相关项目开发

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

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

xorock/zend-service-recaptcha-v2

最新稳定版本:0.1.0

Composer 安装命令:

composer require xorock/zend-service-recaptcha-v2

包简介

Zend Framework 3 service for Google ReCaptcha v2

README 文档

README

#Zend Framework 3 integration with Google ReCaptcha v2

Provides Google ReCaptcha v2 integration for Zend Framework 3.

Installation

Install this library using composer:

$ composer require xorock/zend-service-recaptcha-v2

Then add ZfServiceReCaptcha2 to Your module config under the modules key.

Using Zend Framework Captcha element

use Zend\Form\Element\Captcha;
use ZfServiceReCaptcha2\Captcha\ReCaptcha2;

$this->add([
    'type'       => Captcha::class,
    'name'       => 'g-recaptcha-response', // name is required for element to be validated
    'options'    => [
        'label' => 'Please answer question',
        'captcha' => [
            'class' => ReCaptcha2::class,
            'options' => [
                'hl' => 'en', // english is set by deafult, this line is not required
                'theme' => 'light', // see options below
                'callback' => '', // callback function, etc.
                'public_key'  => 'Generated public key',
                'private_key' => 'Generated private key'
            ],
        ],
    ],
]);

Options

Form element allows two different type of options: params and attributes. Both refer to https://developers.google.com/recaptcha/docs/display configuration options. Parameters are published inside 'script' tag, while the attributes referes to 'div.g-recaptcha element'. By default they are defined as:

/**
 * Parameters for the script object
 *
 * @var array
 */
protected $params = array(
    'onload' => null,
    'render' => 'onload',
    'hl'     => 'en'
);
    
/**
 * Attributes for div element
 *
 * @var array
 */
protected $attributes = array(
    'class'            => 'g-recaptcha',
    'theme'            => 'light',
    'type'             => 'image',
    'tabindex'         => 0,
    'callback'         => null,
    'expired-callback' => null
);

ReCaptcha2 form element

ZfServiceReCaptcha2 component also comes with a predefined element ReCaptcha2, which extends built-in \Zend\Form\Element\Captcha. By default, it consumes following config:

return [
    'zfservicerecaptcha2' => [
        'recaptcha' => [
            'options' => [
                // Captcha options
                'hl' => 'en',
                'public_key'  => 'Generated public key',
                'private_key' => 'Generated private key'
            ],
        ]
    ]
];

It is convenient to set Your ReCaptcha keys and other options in general application configuration. You can use this element by simply defining

use ZfServiceReCaptcha2\Form\Element\ReCaptcha2;

$this->add([
    'type'       => ReCaptcha2::class,
    // Field name is defined by factory
    // 'name'       => 'g-recaptcha-response', 
    'options'    => [
        'label' => 'Please answer question',
    ],
]);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-11-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固