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
Requires
- php: ^8.3
- vincenzoraco/turnstile-php: ^1.1
Requires (Dev)
- laravel/framework: ^12.0
- laravel/pint: ^1.0
- orchestra/canvas: ^10.0
- orchestra/testbench: ^10.0
- pestphp/pest: ^3.7
- phpstan/phpstan: 1.10.56
- rector/rector: 0.19.5
Suggests
- illuminate/contracts: for the Laravel integration
- illuminate/support: for the Laravel integration
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 }