PHPackages                             trisnawan/captcha-gateway - 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. trisnawan/captcha-gateway

ActiveLibrary[Security](/categories/security)

trisnawan/captcha-gateway
=========================

Captcha Gateway is a PHP library that provides integration to secure your website forms with CloudFlare Turnstile or Google ReCaptcha.

1.0.0(5mo ago)00MITPHPPHP &gt;=7.4.0

Since Dec 2Pushed 5mo agoCompare

[ Source](https://github.com/trisnawan/captcha-gateway)[ Packagist](https://packagist.org/packages/trisnawan/captcha-gateway)[ RSS](/packages/trisnawan-captcha-gateway/feed)WikiDiscussions master Synced 1mo ago

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

Captcha Gateway
===============

[](#captcha-gateway)

Captcha Gateway is a PHP library that provides integration to secure your website forms with [CloudFlare Turnstile](https://developers.cloudflare.com/turnstile/) or [Google ReCaptcha](https://docs.cloud.google.com/recaptcha/docs/overview).

To use CloudFlare Turnstile, please create a widget in [CloudFlare Turnstile](https://developers.cloudflare.com/turnstile/get-started/widget-management/dashboard/).

To use Google ReCaptcha, please create a [Google Cloud Console](https://console.cloud.google.com/) project and then create [ReCaptcha](https://console.cloud.google.com/security/recaptcha).

Instalation
-----------

[](#instalation)

```
composer require trisnawan/captcha-gateway
```

Initialization
--------------

[](#initialization)

```
use Trisnawan\CaptchaGateway\Captcha;
```

### Hardcoded

[](#hardcoded)

```
$captcha = new Captcha("VENDOR", "PROJECT", "SITE_KEY", "SECRET_KEY");
```

### Environment

[](#environment)

```
captcha.vendor = VENDOR
captcha.widget = PROJECT
captcha.site.key = SITE_KEY
captcha.secret.key = SECRET_KEY

```

```
$captcha = new Captcha();
```

Note:

- `VENDOR`, `turnstile` or `recaptcha`
- `PROJECT`, ID Project Google ReCaptcha or Widget Name Cloudflare Turnstile
- `SITE_KEY`, Site Key or Public Key
- `SECRET_KEY`, Secret Key or API KEY

Form
----

[](#form)

```
// 1. load script
echo $captcha->client->script();

// 2. render
echo $captcha->client->render("ACTION", "INPUT_ID", "BUTTON_ID");
```

Note:

- `ACTION`, action form, example: login, registration, chart, buy, etc.
- `INPUT_ID`, input id captcha-token (optional)
- `BUTTON_ID`, button submit id (optional)

Example:

```

        Login

```

Validation
----------

[](#validation)

```
// 1. VERIFY - default
$validation = $captcha->server->verify("login-action");

// 1. VERIFY - manual token data
$token = $_POST['captcha-token'];
$validation = $captcha->server->verify("login-action", $token);

// 1. VERIFY - manual token data + IP verification
$ip = $_SERVER['HTTP_CLIENT_IP'] ?? $_SERVER['REMOTE_ADDR'] ?? null;
$token = $_POST['captcha-token'];
$validation = $captcha->server->verify("login-action", $token, $ip);

// 2. CHECK VALIDATION
if(!$validation->isSuccess){
    $messageError = $validation->errorMessage;
    $arrayErrors = $validation->errors;
    // show error
}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance77

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

157d ago

### Community

Maintainers

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

---

Top Contributors

[![trisnawan](https://avatars.githubusercontent.com/u/64518006?v=4)](https://github.com/trisnawan "trisnawan (1 commits)")

---

Tags

recaptchacaptchaturnstile

### Embed Badge

![Health badge](/badges/trisnawan-captcha-gateway/health.svg)

```
[![Health](https://phpackages.com/badges/trisnawan-captcha-gateway/health.svg)](https://phpackages.com/packages/trisnawan-captcha-gateway)
```

###  Alternatives

[phelium/recaptcha

reCAPTCHA v2 class

4389.4k](/packages/phelium-recaptcha)[usarise/turnstile

PHP library for Turnstile, is Cloudflare’s smart CAPTCHA alternative. It can be embedded into any website without sending traffic through Cloudflare and works without showing visitors a CAPTCHA.

2393.5k6](/packages/usarise-turnstile)[cakephp-fr/recaptcha

To easily use Google Recaptcha (free CAPTCHA service that protect websites from spam and abuse) in CakePHP projects

1419.3k](/packages/cakephp-fr-recaptcha)[cake17/cakephp-recaptcha

\[DEPRECIATED\] Please use https://github.com/cakephp-fr/recaptcha/

1211.0k1](/packages/cake17-cakephp-recaptcha)

PHPackages © 2026

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