vincenzoraco/turnstile-for-laravel

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

v1.0.0 2025-03-01 07:34 UTC

This package is auto-updated.

Last update: 2025-03-01 10:09:55 UTC


README

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

Note

This package requires PHP 8.2+ and Laravel 11+

Installation

You can install the package via composer:

composer global 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 facade:

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

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