2017 © Pedro Peláez
 

library zf1-recaptcha-2

A quick package to assist with using Google reCAPTCHA version 2 with ZF1

image

cgsmith/zf1-recaptcha-2

A quick package to assist with using Google reCAPTCHA version 2 with ZF1

  • Saturday, February 4, 2017
  • by cgsmith
  • Repository
  • 5 Watchers
  • 6 Stars
  • 6,182 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 12 Forks
  • 6 Open issues
  • 6 Versions
  • 14 % Grown

The README.md

ZF1 reCAPTCHA2 - Google reCAPTCHA integration

ZF1 ships with Google reCAPTCHA version 1. Now that version 2 is available you will probably want to use an up-to-date element for your Zend Framework installations., (*1)

Installation

Composer Install

"require": {
    "cgsmith/zf1-recaptcha-2": "~1.0"
}

Usage

Install the latest version (1.0.1) and setup your plugins and form abstract with the following information:, (*2)

  • On your application.ini or where you want
recaptcha.sitekey = "YOUR SITE KEY GIVEN BY GOOGLE"
recaptcha.secretkey = "YOUR SECRET KEY GIVEN BY GOOGLE"
  • In your bootstrap:
public function _initView()
{
    $view = new Zend_View();

    $view->addHelperPath(
        APPLICATION_PATH . '/../vendor/cgsmith/zf1-recaptcha-2/src/Cgsmith/View/Helper',
        'Cgsmith\\View\\Helper\\'
    );

    Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer($view));

    return $view;
}

public function _initRecaptcha()
{
    $config = \Zend_Registry::get('application');
    $params = $config->recaptcha->toArray();

    $params['messageTemplates'] = [
        \Cgsmith\Validate\Recaptcha::INVALID_CAPTCHA => 'The captcha was invalid', // set custom/translated message
        \Cgsmith\Validate\Recaptcha::CAPTCHA_EMPTY => 'The captcha must be completed'
    ];

    \Zend_Registry::set('recaptcha', $params);
}
  • Below is what you would setup in your form.
<?php

// create your element
$this->addElement(new \Cgsmith\Form\Element\Recaptcha());

  • On your controller, after "validate the post data"
if($form->isValid($_POST)) {
    $values = $form->getValues();
    unset($values['g-recaptcha-response']);
    // Your business logic must be here
}

About

Requirements

  • ZF1 reCAPTCHA2 works with PHP 5.5 or above.

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub, (*3)

Author

Chris Smith - chris@cgsmith.net - http://twitter.com/cgsmith105, (*4)

License

ZF1 reCAPTCHA2 is licensed under the MIT License - see the LICENSE file for details, (*5)

The Versions

04/02 2017

dev-master

9999999-dev

A quick package to assist with using Google reCAPTCHA version 2 with ZF1

  Sources   Download

MIT

The Requires

 

zf1 zend google recaptcha

26/04 2016

1.0.2

1.0.2.0

A quick package to assist with using Google reCAPTCHA version 2 with ZF1

  Sources   Download

MIT

The Requires

 

zf1 zend google recaptcha

26/04 2016

dev-bugfix/adding-correct-namespacing

dev-bugfix/adding-correct-namespacing

A quick package to assist with using Google reCAPTCHA version 2 with ZF1

  Sources   Download

MIT

The Requires

 

zf1 zend google recaptcha

15/04 2015

1.0.1

1.0.1.0

A quick package to assist with using Google reCAPTCHA version 2 with ZF1

  Sources   Download

MIT

The Requires

 

zf1 zend google recaptcha

31/03 2015

dev-zf1-recaptcha-2-1

dev-zf1-recaptcha-2-1

A quick package to assist with using Google reCAPTCHA version 2 with ZF1

  Sources   Download

MIT

The Requires

 

zf1 zend recaptcha

31/03 2015

1.0.0

1.0.0.0

A quick package to assist with using Google reCAPTCHA version 2 with ZF1

  Sources   Download

MIT

The Requires

 

zf1 zend recaptcha