This is how I did it, it might not be the best or correct way but it worked for me:
Add the recaptcha service to your composer.json
file:
"require": {
"Zendframework/zendservice-recaptcha": "2.*"
}
Run composer to get the service. Then you need to specify the ReCaptcha config. I created a separate config file to store the ReCaptcha keys:
//zfcuser.local.php
return array(
'zfcuser' => array(
'form_captcha_options' => array(
'options' => array(
'privkey' => RECAPTCHA_PRIVATE_KEY,
'pubkey' => RECAPTCHA_PUBLIC_KEY,
),
),
),
);
Then ZfcUser
captcha config looks like so, telling it to use the ReCaptcha service:
//zfcuser.global.php
'form_captcha_options' => array(
'class' => 'Zend\Captcha\ReCaptcha',
'options' => array(
'wordLen' => 6,
'expiration' => 300,
'timeout' => 300,
),
),
Edit:
You don't need the recaptcha.global.php
. You can call the config file whatever you like aslong as it ends with .global.php or .local.php. You usually name things .local.php
when you don't want them in version control.
In this case I named the file zfcuser.local.php because all it does is store the ReCaptcha keys and I didn't want them in version control.
All the config files get merged in to one array when the application is started. So basically, ignore the ZfcUser
documentation. Or maybe someone else can explain how to get it working that way.
The third block of code is the zfcuser.global.php.