PHPackages                             silverstripe-terraformers/turnstile-captcha - 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. silverstripe-terraformers/turnstile-captcha

ActiveSilverstripe-vendormodule[Security](/categories/security)

silverstripe-terraformers/turnstile-captcha
===========================================

Silverstripe CMS Turnstile Captcha Spam Protection Field

0.0.4(2y ago)16.6k4[2 PRs](https://github.com/silverstripe-terraformers/turnstile-captcha/pulls)BSD-3-ClausePHPPHP ^8.1

Since Jun 22Pushed 2y ago3 watchersCompare

[ Source](https://github.com/silverstripe-terraformers/turnstile-captcha)[ Packagist](https://packagist.org/packages/silverstripe-terraformers/turnstile-captcha)[ RSS](/packages/silverstripe-terraformers-turnstile-captcha/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

Silverstripe Turnstile CAPTCHA
==============================

[](#silverstripe-turnstile-captcha)

Adds a "spam protection" field to SilverStripe userforms using Cloudflare's [Turnstile CAPTCHA](https://developers.cloudflare.com/turnstile) service.

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

[](#requirements)

- SilverStripe 5.x
- [SilverStripe Spam Protection 4.x](https://github.com/silverstripe/silverstripe-spamprotection/)

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

[](#installation)

```
composer require silverstripe-terraformers/turnstile-captcha

```

After installing the module via composer or manual install you must set the spam protector to TurnstileCaptchaProtector, this needs to be set in your site's config file normally this is mysite/\_config/config.yml.

```
SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension:
    default_spam_protector: Terraformers\TurnstileCaptcha\Forms\TurnstileCaptchaProtector
```

Finally, add the "spam protection" field to your form by calling `enableSpamProtection()` on the form object.

```
$form->enableSpamProtection();
```

Configuration
-------------

[](#configuration)

Set the `site_key` and the `secret_key` via [environment variables](https://docs.silverstripe.org/en/5/getting_started/environment_management/).

```
SS_TURNSTILE_SITE_KEY=""
SS_TURNSTILE_SECRET_KEY=""
```

You can get these from your cloudflare account [refer to the turnstile documentation](https://developers.cloudflare.com/turnstile/).

There are some optional configuration settings that can be added to your site's yaml config (typically this is mysite/\_config/config.yml).

```
Terraformers\TurnstileCaptcha\Forms\TurnstileCaptchaField:
    default_theme: "light" #Default theme color (optional, light or dark, defaults to auto)
    default_render_type: 'explicit' #Default setting for how to render the widget. See the "Render Type" section below.
```

TurnstileCaptchaField uses Guzzle to communicate with cloudflare. If you would like to change http connection settings (Eg proxy settings) you can configure your own HttpClient class via injector

```
SilverStripe\Core\Injector\Injector:
    Terraformers\TurnstileCaptcha\Http\HttpClient:
        class: App\HttpClient
```

Adding field labels
-------------------

[](#adding-field-labels)

If you want to add a field label or help text to the TurnstileCaptchaField field you can do so like this:

```
$form->enableSpamProtection()
    ->fields()->fieldByName('TurnstileCaptchaField')
    ->setTitle("Spam protection")
    ->setDescription("Please tick the box to prove you're a human and help us stop spam.");
```

### Commenting Module

[](#commenting-module)

When your using the [silverstripe/comments](https://github.com/silverstripe/silverstripe-comments)module you must add the following (per their documentation) to your \_config.php in order to use Terraformers\\TurnstileCaptcha on comment forms.

```
CommentingController::add_extension('CommentSpamProtection');
```

Render type
-----------

[](#render-type)

By default, the turnstyle widget will be rendered automatically. To change this you can set the render type.

This can be configured site-wide using the Config API

```
Terraformers\TurnstileCaptcha\Forms\TurnstileCaptchaField:
    default_render_type: 'explicit'
```

Or on a per form basis:

```
$captchaField = $form->Fields()->fieldByName('TurnstileCaptchaField');
$captchaField->setRenderType('explicit');
```

With this configuration you will need to add your own javascript to render the widget. Refer to the [cloudflare documentation](https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/#explicitly-render-the-turnstile-widget) for details.

Reporting an issue
------------------

[](#reporting-an-issue)

When you're reporting an issue please ensure you specify what version of SilverStripe you are using i.e. 3.1.3, 3.2beta, master etc. Also be sure to include any JavaScript or PHP errors you receive, for PHP errors please ensure you include the full stack trace. Also please include how you produced the issue. You may also be asked to provide some of the classes to aid in re-producing the issue. Stick with the issue, remember that you seen the issue not the maintainer of the module so it may take allot of questions to arrive at a fix or answer.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.5% 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 ~6 days

Total

4

Last Release

1037d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/948122?v=4)[Bernard Hamlin](/maintainers/blueo)[@blueo](https://github.com/blueo)

---

Top Contributors

[![blueo](https://avatars.githubusercontent.com/u/948122?v=4)](https://github.com/blueo "blueo (6 commits)")[![DevKCode](https://avatars.githubusercontent.com/u/365647?v=4)](https://github.com/DevKCode "DevKCode (5 commits)")

---

Tags

silverstriperecaptchaspamprotectionturnstile

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/silverstripe-terraformers-turnstile-captcha/health.svg)

```
[![Health](https://phpackages.com/badges/silverstripe-terraformers-turnstile-captcha/health.svg)](https://phpackages.com/packages/silverstripe-terraformers-turnstile-captcha)
```

###  Alternatives

[undefinedoffset/silverstripe-nocaptcha

A spam protector and form field using Google's reCAPTCHA v2 or optionally a foundation v3 implementation

33471.6k16](/packages/undefinedoffset-silverstripe-nocaptcha)[silverstripe/auditor

Adds security audit trail to SilverStripe.

10352.1k5](/packages/silverstripe-auditor)[exadium/silverstripe-invisible-spam-protection

Very simple anti spam protection based on principle that automated spammers enter bogus information in all form fields. Field is added to form that is hidden using CSS hiding it from human users. Form is only allowed to be submitted if field is empty. Includes an EditableInvisibleSpamField to integrate with the UserForms module.

112.1k](/packages/exadium-silverstripe-invisible-spam-protection)

PHPackages © 2026

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