PHPackages                             kagurati/captchautils - 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. kagurati/captchautils

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

kagurati/captchautils
=====================

PHP classes for interacting with CF Turnstile, hCaptcha, or ALTCHA

v1.1.0(1y ago)029UnlicensePHPPHP &gt;=8.0

Since Jul 9Pushed 1y agoCompare

[ Source](https://github.com/Zanaras/captchautils)[ Packagist](https://packagist.org/packages/kagurati/captchautils)[ RSS](/packages/kagurati-captchautils/feed)WikiDiscussions main Synced 1w ago

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

CAPTCHAUtils
============

[](#captchautils)

Set of PHP classes to reduce duplication of code used to verify various CAPTCHA-esque things (Cloudflare Turnstile and hCAPTCHA) that don't have their own maintained packages. Google's ReCAPTCHA is deliberately omitted since they publish their own PHP package.

ALTCHA support may be added when I can verify that their own libraries don't support their open source implementation of CATPCHA.

Requirements
------------

[](#requirements)

- PHP 8.0+
- PHP JSON and CURL extensions.

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

[](#installation)

`composer install kagurati/captchautils`

Usage
-----

[](#usage)

Both the Turnstile and hCaptcha classes work nearly identically, in that they both expect the client response string and optionally accept the user's IP for additional validation. Turnstile additonally also accepts an [idempotency key](https://developers.cloudflare.com/turnstile/get-started/server-side-validation/) which can be used to allow reuse of the response string while hCaptcha has support for sending the Site Key during server validation to prevent cross-site scripting attacks.

Both have verify functions that return a multidimensional array of the response pass/fail or, in case of a curl failure, 'error' as the first value. The entire validation response included as the second value if your application needs to analyze it further.

Psuedocode examples are below:

### Turnstile

[](#turnstile)

```
...
use CAPTCHAUtils\Turnstile;
...
private string $yourTunrstileSecretKey = '1234abcd';
...
public function checkThisUser($clientResponseString, $userIP = null, $idempotencyKey = null) {
        $check = new Turnstile($this->yourTurnstileSecretKey)->verify($clientResponseString, $userIP, $idempotencyKey);
        if ($check[0]) {
                # User is a real human!
        } else {
                # User probably isn't a real human.
                $errors = $check[1]['error-codes'];
        }
}
```

### hCaptcha

[](#hcaptcha)

```
...
use CAPTCHAUtils\hCaptcha;
...
private string $yourhCaptchaSecretKey = '1234abcd';
...
public function checkThisUser($clientResponseString, $userIP = null, $expectedSiteKey = null) {
        $check = new hCaptcha($this->yourhCaptchaSecretKey)->verify($clientResponseString, $userIP, $expectedSiteKey);
        if ($check[0]) {
                # User is a real human!
        } else {
                # User probably isn't a real human.
        }
}
```

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance46

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

405d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d36c8b036e3d5b8bd693ca58692e83babad13b6b75badd82ef7dbaa6a6d7f2bc?d=identicon)[kagurati](/maintainers/kagurati)

---

Top Contributors

[![Zanaras](https://avatars.githubusercontent.com/u/11413877?v=4)](https://github.com/Zanaras "Zanaras (10 commits)")

### Embed Badge

![Health badge](/badges/kagurati-captchautils/health.svg)

```
[![Health](https://phpackages.com/badges/kagurati-captchautils/health.svg)](https://phpackages.com/packages/kagurati-captchautils)
```

###  Alternatives

[arm092/livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS

3060.2k](/packages/arm092-livewire-datatables)[hirasso/focal-point-picker

Zero-dependency custom focal point picker for your WordPress images 🎯

428.8k](/packages/hirasso-focal-point-picker)[sitegeist/inspectorgadget

Edit value objects in the inspector

1347.1k2](/packages/sitegeist-inspectorgadget)[kirbyzone/sitemapper

Kirbyzone's Automatic Sitemap Generator Plugin for Kirby

103.5k](/packages/kirbyzone-sitemapper)

PHPackages © 2026

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