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

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

mashkin/recaptcha-serviceprovider
=================================

Provides Google's ReCaptcha API as a Silex ServiceProvider

v2.0(8y ago)14091MITPHP

Since Aug 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Mashkin/RecaptchaServiceProvider)[ Packagist](https://packagist.org/packages/mashkin/recaptcha-serviceprovider)[ RSS](/packages/mashkin-recaptcha-serviceprovider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

RecaptchaServiceProvider
========================

[](#recaptchaserviceprovider)

Silex ServiceProvider integrating Google's ReCaptcha service

Installation
------------

[](#installation)

Through Composer
----------------

[](#through-composer)

Add this package to your `composer.json` file and `composer update`

```
{
  ...
  "require": {
    ...
    "mashkin/recaptcha-serviceprovider": "dev-master"
  }
}

```

Or simply do `composer require "mashkin/recaptcha-serviceprovider" "dev-master"`.

Usage
-----

[](#usage)

### As ServiceProvider

[](#as-serviceprovider)

Register the `RecaptchaServiceProvider` and provide your configuration:

```
$app->register(new Mashkin\RecaptchaServiceProvider(), array(
  'recaptcha.sitekey' => 'YOUR_SITE_KEY',
  'recaptcha.secret'  => 'YOUR_SITE_SECRET'
));

// Optional:
// Set language parameter that will be passed to ReCaptcha (default: en)
$app['recaptcha.language'] = 'de';
// Set stream context for API call (file_get_contents()) (default: null)
$app['recaptcha.streamContext'] = ...;

```

On `Application::boot()`, `$app['recaptcha.language']` will be set to `$app['locale']`.

The ServiceProvider provides an instance of `Mashkin\Recaptcha` as `$app['recaptcha']`.
Use it as described below.

### Standalone

[](#standalone)

```
// Do your configuration
// Required:
$siteKey    = 'YOUR_SITE_KEY';
$siteSecret = 'YOUR_SITE_SECRET';

// Optional:
$language = 'de';
$streamContext = ...; // Passed to file_get_contents()

// Create an instance of Mashkin\Recaptcha
$recaptcha = new Recaptcha($siteKey, $siteSecret, $language, $streamContext)

// Get ReCpatcha widget code
// Get target element
echo $recaptcha->getHtmlElement();
// Get JavaScript
echo $recaptcha->getHtmlScript();

// Verify Captcha response
if (isset($_POST['g-recaptcha-response'])) {
  $result = $recaptcha->checkResponse($_POST['g-recaptcha-response']);
  if ($result['success']) {
    echo "Success";
  } else {
    echo "Some errors occured: ";
    echo implode(', ', $result['error-codes']);
    die();
  }
} else {
  die('No captcha response submitted');
}

```

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~359 days

Total

3

Last Release

3212d ago

Major Versions

v1.1 → v2.02017-07-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/47c3b6c0ca4169d985fd3339e43e4870c7632386c9a974dfa5c8f67fa77a68ad?d=identicon)[Mashkin](/maintainers/Mashkin)

---

Top Contributors

[![Mashkin](https://avatars.githubusercontent.com/u/1668814?v=4)](https://github.com/Mashkin "Mashkin (11 commits)")

---

Tags

recaptchacaptchasilexserviceprovider

### Embed Badge

![Health badge](/badges/mashkin-recaptcha-serviceprovider/health.svg)

```
[![Health](https://phpackages.com/badges/mashkin-recaptcha-serviceprovider/health.svg)](https://phpackages.com/packages/mashkin-recaptcha-serviceprovider)
```

###  Alternatives

[pixelopen/cloudflare-turnstile-bundle

A simple package to help integrate Cloudflare Turnstile on Symfony.

31205.8k3](/packages/pixelopen-cloudflare-turnstile-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
