subbee/turnstile-validator

Laravel 5.4+ compatible Turnstile validator

dev-main 2025-04-29 10:22 UTC

This package is auto-updated.

Last update: 2025-04-29 10:25:23 UTC


README

Tests Latest Version on Packagist License

A simple and flexible Laravel package to integrate Cloudflare Turnstile CAPTCHA validation into your applications.

Features

  • Easy Turnstile integration
  • Validation rule for forms
  • Blade directive for widget embedding
  • Configurable via .env
  • Laravel 5.x, 6.x, 7.x, 8.x, 9.x, 10.x compatible

Installation

composer require subbee/turnstile-validator

Publish configuration (optional):

php artisan vendor:publish --tag=config --provider="TurnstileValidator\TurnstileServiceProvider"

Add .env variables

TURNSTILE_SITEKEY=your-sitekey-here
TURNSTILE_SECRET=your-secret-key-here

Getting Cloudflare Turnstile keys

  1. Go to Cloudflare Turnstile Dashboard.
  2. Log in or create an account.
  3. Navigate to Access > Turnstile.
  4. Click “Add Site”, set the domain and widget mode.
  5. Copy your Site Key and Secret Key into .env.

Usage

Validation

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

Blade directive

<form method="POST" action="/submit">
    @csrf
    @turnstile
    <button type="submit">Submit</button>
</form>