Instalamos el servicio ReCaptcha.

Una vez instalado ya podemos utilizarlo en nuestros controladores.
Ejemplo:
public function captchaAction(){
$title="ReCaptcha en Zend Framework 2";
//Una vez nos registramos en ReCaptcha nos da una clave pública y otra privada
$pubKey="string alfanumérico clave pública";
$privKey="string alfanumérico clave privada";
//Instanciamos el servicio ReCaptcha le pasamos las claves y las opciones.
$recaptcha=new \ZendService\ReCaptcha\ReCaptcha($pubKey,$privKey,null, array("theme"=>"white","lang"=>"es"));
//Si se ha enviado el captcha
if(isset($_POST["recaptcha_challenge_field"])){
$result = $recaptcha->verify($_POST['recaptcha_challenge_field'],$_POST['recaptcha_response_field']);
//Comprueba la validez del captcha
if(!$result->isValid()) {
$title .=" - Captcha Incorrecto";
}else{
$title .=" - Captcha Correcto";
}
}
return new ViewModel(
array(
"title"=>$title,
"recaptcha"=>$recaptcha
)
);
}
La vista:
<h2><?php echo $this->title?></h2>
<form action="" method="post">
<!--Imprimimos el campo del Captcha-->
<?php echo $recaptcha->getHTML();?>
<input type="submit" value="Enviar" class="btn btn-warning"/>
</form>
Más información:
http://framework.zend.com/manual/2.3/en/modules/zendservice.re-captcha.html
http://www.daredevel.com/recaptcha-in-zend-framework-2-project-using-zendform-component/
https://groups.google.com/forum/#!topic/recaptcha/ZHgLI8p7hcI
https://www.google.com/recaptcha
https://developers.google.com/recaptcha/docs/customization














