Laravel package to facilitate the server side validation of Cloudflare's Turnstile captcha service.
vincenzoraco/turnstile-for-laravel is a Laravel package for laravel package to facilitate the server side validation of cloudflare's turnstile captcha service..
It currently has 1 GitHub stars and 74 downloads on Packagist (latest version v2.0.0).
Install it with composer require vincenzoraco/turnstile-for-laravel.
Discover more Laravel packages by vincenzoraco
or browse all Laravel packages to compare alternatives.
Last updated
A package to facilitate the server side validation of Cloudflare's Turnstile captcha service.
[!NOTE] This package requires PHP 8.3+ and Laravel 11+
You can install the package via composer:
composer require vincenzoraco/turnstile-for-laravel
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_KEYis 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
}