Skip to content
This repository has been archived by the owner on Jun 24, 2023. It is now read-only.

Zend Framework 1 integration for Google reCAPTCHA version 2.0

License

Notifications You must be signed in to change notification settings

wendrowycz/zf1-recaptcha-2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Installation

Composer Install

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

Usage

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

  • On your application.ini or where you want
recaptcha.sitekey = "YOUR SITE KEY GIVED BY GOOGLE"
recaptcha.secretkey = "YOUR SECRET KEY GIVED BY GOOGLE"
  • In your controller:
<?php
$this->view->headScript()->appendFile('//www.google.com/recaptcha/api.js'); 
$this->view->addHelperPath(APPLICATION_PATH . 'Wendrowycz', 'Wendrowycz');
  • In the init() function of your Form
 $this->addPrefixPath('Wendrowycz\\Form\\Element', APPLICATION_PATH . '/../vendor/wendrowycz/zf1-recaptcha-2/src/Wendrowycz/Form/Element', Zend_Form::ELEMENT);
 $this->addElementPrefixPath('Wendrowycz\\Validate\\', APPLICATION_PATH . '/../vendor/wendrowycz/zf1-recaptcha-2/src/Wendrowycz/Validate/', Zend_Form_Element::VALIDATE);
  • Below is what you would setup in your form.
<?php

// create your element and pass through your site key and secret key
$this->addElement('Recaptcha', 'g-recaptcha-response', [
    'siteKey'   => Zend_Registry::get('application')->recaptcha->sitekey,
    'secretKey' => Zend_Registry::get('application')->recaptcha->secretkey,
]);
  • 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

Author

Chris Smith - chris@cgsmith.net - http://twitter.com/cgsmith105

License

ZF1 reCAPTCHA2 is licensed under the MIT License - see the LICENSE file for details

About

Zend Framework 1 integration for Google reCAPTCHA version 2.0

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 84.7%
  • HTML 10.2%
  • ApacheConf 5.1%