vincenzoraco/turnstile-for-laravel

Laravel package to facilitate the server side validation of Cloudflare's Turnstile captcha service.

Maintainers

Package info

github.com/vincenzoraco/turnstile-for-laravel

pkg:composer/vincenzoraco/turnstile-for-laravel

Statistics

Installs: 71

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v2.0.0 2026-04-16 04:09 UTC

README

A package to facilitate the server side validation of Cloudflare's Turnstile captcha service.

Note

This package requires PHP 8.3+ and Laravel 11+

Installation

You can install the package via composer:

composer require vincenzoraco/turnstile-for-laravel

Usage

Once installed, set the following ENV:

TURNSTILE_SECRET_KEY=
TURNSTILE_SITE_KEY=

Then publish the config file:

php artisan vendor:publish --tag=turnstile-config

Note

TURNSTILE_SITE_KEY is only for your convenience to have it in the config

You can then use the validation rule:

use VincenzoRaco\TurnstileLaravel\Rules\TurnstileCheck;

$request->validate([
    'cf-turnstile-response' => ['required', new TurnstileCheck],
]);

Or use the facade directly:

use VincenzoRaco\Turnstile\DataObjects\TurnstileValidateDTO;
use VincenzoRaco\TurnstileLaravel\Facades\Turnstile;

$result = Turnstile::validate(new TurnstileValidateDTO(
    $token,
));

if ($result->isFailure()) {
    throw new CaptchaException; // custom exception
}