subbee / turnstile-validator
Laravel 5.4+ compatible Turnstile validator
dev-main
2025-04-29 10:22 UTC
Requires
- php: >=5.6.0
This package is auto-updated.
Last update: 2025-04-29 10:25:23 UTC
README
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
- Go to Cloudflare Turnstile Dashboard.
- Log in or create an account.
- Navigate to Access > Turnstile.
- Click “Add Site”, set the domain and widget mode.
- 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>