PHPackages                             neutron/recaptcha - 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. neutron/recaptcha

ActiveLibrary

neutron/recaptcha
=================

ReCaptcha Client

0.1.3(13y ago)29156.2k↑50%13[2 PRs](https://github.com/romainneutron/ReCaptcha/pulls)2MITPHP

Since Feb 13Pushed 9y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (5)Used By (2)

Guzzled PHP ReCaptcha
=====================

[](#guzzled-php-recaptcha)

[![Build Status](https://camo.githubusercontent.com/7ad2d7897d2486b2624a1cb80e140d5cc41411b9192702174e9e4805efebba0f/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f726f6d61696e6e657574726f6e2f5265436170746368612e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/romainneutron/ReCaptcha)

This is a Object Oriented PHP port of the original ReCaptcha lib.

It's been designed to be testable and uses [Guzzle](http://guzzlephp.org) as a transport layer.

- see

Install
-------

[](#install)

The recommended way to use ReCaptcha is [through composer](http://getcomposer.org).

```
{
    "require": {
        "neutron/recaptcha": "~0.1.0"
    }
}
```

Silex Service Provider
----------------------

[](#silex-service-provider)

A simple [Silex](http://silex.sensiolabs.org) service provider :

```
use Neutron\ReCaptcha\ReCaptcha;
use Neutron\ReCaptcha\ReCaptchaServiceProvider;
use Silex\Application;

$app = new Application();
$app->register(new ReCaptchaServiceProvider(), array(
    'recaptcha.public-key'  => 'fdspoksqdpofdkpopgqpdskofpkosd',
    'recaptcha.private-key' => 'lsdmkzfqposfomkcqdsofmsdkfkqsdmfmqsdm',
));

// $captcha is an instance of Neutron\ReCaptcha\Response
$captcha = $app['recaptcha']->bind($app['request']);

if ($captcha->isValid()) {
    echo "YEAH !";
} else {
    echo "Too bad dude :( " . $captcha->getError();
}
```

Usage Example
-------------

[](#usage-example)

To display a captcha to the client :

- Initialize your captcha object :

```
use Neutron\ReCaptcha\ReCaptcha;

$recaptcha = ReCaptcha::create($publicKey, $privateKey);
```

- In your template :

```

    var RecaptchaOptions = {
       theme : 'custom',
       custom_theme_widget: 'recaptcha_widget'
    };

        Incorrect please try again

        Enter the words above:
        Enter the numbers you hear:

        Get another CAPTCHA
        Get an audio CAPTCHA
        Get an image CAPTCHA

        Help
