notafacil/zf3-coinhive-captcha

CoinHive Captcha module for Zend Framework 2 & 3 (ZF2 / ZF3)

2.0.1 2018-04-05 19:17 UTC

This package is not auto-updated.

Last update: 2024-04-20 08:30:14 UTC


README

Simple way to use the coinhive.com captcha

Installation

with composer

Just add the following line to your requirements:

composer require notafacil/zf3-coinhive-captcha

and run

php composer.phar update

Since there are problems with the SSL-Cert if you use Adapter\Socket, please install php-curl!

Then activate the module in your application.config.php :

```php
return array(
    'modules' => array(
        // ...
        'CoinHiveCaptcha',
    ),
    // ...
);
```

Get your private-key

To use this service, you have to register at CoinHive using your CoinHive Account.

Usage

with Zend\From

Just add the following lines to your form creation:

$element = new \Zend\Captcha\Captcha('coinhive-captcha-token');
$element->setCaptcha(new CoinHiveCaptcha\CoinHiveCaptcha(array('secret_key' => 'YOUR_SECRET', 'public_key' => 'YOUR_PUBLIC_KEY', 'hashes' => 512)));
$form->add($element);

Remember to add this element to your validationChain as well.

It acts the same way as any other built-in captcha solution.

with ServiceManager

If you like to implement the view on your own, just use the Service\CoinHiveCaptchaService. It handles the whole communication between your code and the CoinHive API.

$recaptcha = $serviceLocator->get('CoinHiveCaptcha\Service\CoinHiveCaptchaService');