romanzipp / laravel-turnstile
Cloudflare Turnstile package for Laravel
Fund package maintenance!
romanzipp
Installs: 48 480
Dependents: 0
Suggesters: 0
Security: 0
Stars: 31
Watchers: 3
Forks: 3
Open Issues: 1
Requires
- php: ^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.5
- orchestra/testbench: >=3.8
- phpstan/phpstan: ^0.12.99|^1.0
- phpunit/phpunit: ^8.0|^9.0
- romanzipp/php-cs-fixer-config: ^3.0
README
Cloudflare Turnstile CAPTCHA package for Laravel.
Installation
composer require romanzipp/laravel-turnstile
Configuration
Copy configuration to project:
php artisan vendor:publish --provider="romanzipp\Turnstile\Providers\TurnstileServiceProvider"
Add environmental variables to your .env
:
TURNSTILE_SITE_KEY=
TURNSTILE_SECRET_KEY=
Usage
Laravel Rule
use romanzipp\Turnstile\Rules\TurnstileCaptcha; $payload = $request->validate([ 'cf-turnstile-response' => ['required', 'string', new TurnstileCaptcha()], ]);
Templates
Document head
Injects the script tag. See method signature for more options.
{{ romanzipp\Turnstile\Captcha::getScript() }}
Form
Injects the form element. See method signature for more options.
{{ romanzipp\Turnstile\Captcha::getChallenge() }}
Manual validation (optional)
use romanzipp\Turnstile\Validator; $validator = new Validator(); $response = $validator->validate('input-token'); if ($response->isValid()) { return true; } echo $response->getMessage();
Development
Run Tests
composer test
License
Released under the MIT License.