PHPackages                             cgsmith/zf1-recaptcha-2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cgsmith/zf1-recaptcha-2

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cgsmith/zf1-recaptcha-2
=======================

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

1.0.2(10y ago)8160.0k↓33.3%8[5 issues](https://github.com/cgsmith/zf1-recaptcha-2/issues)MITPHPPHP &gt;=5.5.0

Since Mar 31Pushed 8y ago4 watchersCompare

[ Source](https://github.com/cgsmith/zf1-recaptcha-2)[ Packagist](https://packagist.org/packages/cgsmith/zf1-recaptcha-2)[ RSS](/packages/cgsmith-zf1-recaptcha-2/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (6)Used By (0)

ZF1 reCAPTCHA2 - Google reCAPTCHA integration
=============================================

[](#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
------------

[](#installation)

#### Composer Install

[](#composer-install)

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

```

Usage
-----

[](#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 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.

```
