PHPackages                             mcaskill/charcoal-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. [Security](/categories/security)
4. /
5. mcaskill/charcoal-recaptcha

ActiveLibrary[Security](/categories/security)

mcaskill/charcoal-recaptcha
===========================

Google reCAPTCHA for Charcoal.

v0.5.0(8y ago)12.0k2MITPHPPHP &gt;=5.6.0 || &gt;=7.0

Since Mar 2Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/mcaskill/charcoal-recaptcha)[ Packagist](https://packagist.org/packages/mcaskill/charcoal-recaptcha)[ RSS](/packages/mcaskill-charcoal-recaptcha/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (8)Versions (8)Used By (0)

Google reCAPTCHA for Charcoal
=============================

[](#google-recaptcha-for-charcoal)

[![License](https://camo.githubusercontent.com/2242eb964ce77cc372af55ca312c8ec1a8cc59fbd51822b4e8cafef3c684463b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6361736b696c6c2f63686172636f616c2d7265636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mcaskill/charcoal-recaptcha)[![Latest Stable Version](https://camo.githubusercontent.com/eadfdca9578a4e66b964baad16d23f9a9454ed013342b3e3b4501ba91aff2a46/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6361736b696c6c2f63686172636f616c2d7265636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mcaskill/charcoal-recaptcha)[![Code Quality](https://camo.githubusercontent.com/1c9029768c91b57a28282a7cb63e43b3c0b3de1455ebfa69e44dce6338507ed5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d6361736b696c6c2f63686172636f616c2d7265636170746368612e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/mcaskill/charcoal-recaptcha/)[![Coverage Status](https://camo.githubusercontent.com/e608e135eb53958f8ee150cc61ce5a77baac8648e51e42e593dcca8d6404f1bd/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6d6361736b696c6c2f63686172636f616c2d7265636170746368612e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/mcaskill/charcoal-recaptcha)[![Build Status](https://camo.githubusercontent.com/7c17719bb770664796fb9eab3d25a3bddf230c3621c7c6d3601845fd0812e79b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d6361736b696c6c2f63686172636f616c2d7265636170746368612e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/mcaskill/charcoal-recaptcha)

[![Google reCAPTCHA for Charcoal](https://camo.githubusercontent.com/b4f602af317614a0b04f8dd9cb639f9576005952e45b3bc9bb73fe31e01ea2eb/687474703a2f2f692e696d6775722e636f6d2f6148424f7141532e676966)](https://camo.githubusercontent.com/b4f602af317614a0b04f8dd9cb639f9576005952e45b3bc9bb73fe31e01ea2eb/687474703a2f2f692e696d6775722e636f6d2f6148424f7141532e676966)

A [Charcoal](https://packagist.org/packages/locomotivemtl/charcoal-app) service provider for the [Google reCAPTCHA client Library](https://packagist.org/packages/google/recaptcha).

This package can be used as a PSR-7 middleware or as an object in your service layer.

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

[](#installation)

```
composer require mcaskill/charcoal-recaptcha
```

See [`composer.json`](composer.json) for depenencides.

What's inside?
--------------

[](#whats-inside)

- **`Charcoal\ReCaptcha\CaptchaServiceProvider`**: Service provider.
- **`Charcoal\ReCaptcha\CaptchaConfig`**: Configuring the CAPTCHA service.
- **`Charcoal\ReCaptcha\CaptchaAwareTrait`**: Convenient trait for interfacing with the CAPTCHA service.
- **`Charcoal\ReCaptcha\Captcha`**: Service that handles the reCAPTCHA client.
- **`Charcoal\ReCaptcha\LocalizedCaptcha`**: [Translator-aware](https://packagist.org/packages/locomotivemtl/charcoal-translator) variant of the service.

Usage
-----

[](#usage)

```
use Charcoal\ReCaptcha\Captcha;

$captcha = new Captcha([
    'config' => [
        'public_key'  => '…',
        'private_key' => '…',
    ]
]);

// As middleware
$app->post('/signup', '…')->add($captcha);

// As standalone, with direct user input
$captcha->verify($input, $ip);

// With a PSR-7 request
$captcha->verifyRequest($request);

// Display the widget in your views
echo $captcha->display(
    [
        'data-theme' => 'dark',
        'data-type' =>  'audio',
    ],
    [
        'hl' => 'fr'
    ]
);
```

By default, the `Captcha` adapter will defer the instantiation of [`ReCaptcha`](https://github.com/google/recaptcha/blob/1.1.3/src/ReCaptcha/ReCaptcha.php) until the first verification request.

### Custom ReCaptcha Class

[](#custom-recaptcha-class)

The `ReCaptcha` class be swapped using the `client_class` option.

```
use Charcoal\ReCaptcha\Captcha;
use MyApp\ MyCustomReCaptcha;

$captcha = new Captcha([
    'config' => [
        'public_key'  => '…',
        'private_key' => '…',
    ],
    'client_class' =>  MyCustomReCaptcha::class
]);
```

### Custom ReCaptcha Instance

[](#custom-recaptcha-instance)

An instance of the `ReCaptcha` class can be assigned using the `client` option.

```
use Charcoal\ReCaptcha\Captcha;
use ReCaptcha\ReCaptcha;
use ReCaptcha\RequestMethod\CurlPost;

$client = new ReCaptcha('…', new CurlPost());

$captcha = new Captcha([
    'config' => [
        'public_key'  => '…',
        'private_key' => '…',
    ],
    'client' => $client
]);
```

Service Provider
----------------

[](#service-provider)

If [`CaptchaServiceProvider`](src/CaptchaServiceProvider.php) is used, the following are provided.

### Parameters

[](#parameters)

- **charcoal/captcha/config**: An instance of [`CaptchaConfig`](src/CaptchaConfig.php).

### Services

[](#services)

- **charcoal/captcha**: An instance of [`Captcha`](src/CaptchaConfig.php).

### Registering

[](#registering)

Via Charcoal configuration file:

```
{
    "apis": {
        "google": {
            "recaptcha": {
                "public_key": "…",
                "private_key": "…"
            }
        },
    },
    "service_providers": {
        "charcoal/re-captcha/captcha": {}
    }
}
```

Via PHP:

```
$container->register(new Charcoal\ReCaptcha\CaptchaServiceProvider(), [
    'charcoal/captcha/config' => [
        'public_key'  => '…',
        'private_key' => '…'
    ]
]);
```

Acknowledgements
----------------

[](#acknowledgements)

This package is inspired by:

- [`geggleto/psr7-recaptcha`](https://github.com/geggleto/psr7-recaptcha)
- [`anhskohbo/no-captcha`](https://github.com/anhskohbo/no-captcha)
- [`buzz/laravel-google-captcha`](https://github.com/thinhbuzz/laravel-google-captcha)

License
-------

[](#license)

- Charcoal reCAPTCHA component is licensed under the MIT license. See [LICENSE](LICENSE) for details.
- Charcoal framework is licensed under the MIT license. See [LICENSE](https://github.com/locomotivemtl/charcoal-app/blob/master/LICENSE) for details.
- Google reCAPTCHA PHP client library is licensed under the BSD License. See the [LICENSE](https://github.com/google/recaptcha/blob/master/LICENSE) file for details.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.2% 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 ~89 days

Recently: every ~110 days

Total

6

Last Release

2963d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.6

v0.4.1PHP &gt;=5.6.0 || &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a4f39523b4b2837562ba0848a0327b8d340118d1ba87cb0f5d59b1d5cb6beba?d=identicon)[mcaskill](/maintainers/mcaskill)

---

Top Contributors

[![mcaskill](https://avatars.githubusercontent.com/u/29353?v=4)](https://github.com/mcaskill "mcaskill (25 commits)")[![MouseEatsCat](https://avatars.githubusercontent.com/u/9273580?v=4)](https://github.com/MouseEatsCat "MouseEatsCat (3 commits)")[![dominiclord](https://avatars.githubusercontent.com/u/1775204?v=4)](https://github.com/dominiclord "dominiclord (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mcaskill-charcoal-recaptcha/health.svg)

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[oat-sa/tao-core

TAO core extension

66143.7k124](/packages/oat-sa-tao-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

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