PHPackages                             ryangjchandler/laravel-cloudflare-turnstile - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ryangjchandler/laravel-cloudflare-turnstile

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ryangjchandler/laravel-cloudflare-turnstile
===========================================

A simple package to help integrate Cloudflare Turnstile.

v3.0.3(2mo ago)438896.6k↓14.5%30[1 issues](https://github.com/ryangjchandler/laravel-cloudflare-turnstile/issues)[2 PRs](https://github.com/ryangjchandler/laravel-cloudflare-turnstile/pulls)2MITPHPPHP ^8.2CI passing

Since Sep 30Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/ryangjchandler/laravel-cloudflare-turnstile)[ Packagist](https://packagist.org/packages/ryangjchandler/laravel-cloudflare-turnstile)[ Docs](https://github.com/ryangjchandler/laravel-cloudflare-turnstile)[ RSS](/packages/ryangjchandler-laravel-cloudflare-turnstile/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (28)Versions (18)Used By (2)

A simple package to help integrate Cloudflare Turnstile.
========================================================

[](#a-simple-package-to-help-integrate-cloudflare-turnstile)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ffa06069567072bc80a050f7af3a9f6f4d86ff633f5ed6d5d41035511f7198a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7279616e676a6368616e646c65722f6c61726176656c2d636c6f7564666c6172652d7475726e7374696c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ryangjchandler/laravel-cloudflare-turnstile)[![GitHub Tests Action Status](https://camo.githubusercontent.com/32114ec610c83e07fe1d2387c006298ee03e2ccdf7ddf04b2ff531d634bd88a8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7279616e676a6368616e646c65722f6c61726176656c2d636c6f7564666c6172652d7475726e7374696c652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d7465737473)](https://github.com/ryangjchandler/laravel-cloudflare-turnstile/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/17d890072c452a8dd94b640cd3f51a0593a3458cb4fc0329944c1a375c002e19/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7279616e676a6368616e646c65722f6c61726176656c2d636c6f7564666c6172652d7475726e7374696c652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d636f64652b7374796c65)](https://github.com/ryangjchandler/laravel-cloudflare-turnstile/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/9360ebe22b22980b72eba1c079ddbc48c97365b05ec0583c2a0f5f1e1b698ec6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7279616e676a6368616e646c65722f6c61726176656c2d636c6f7564666c6172652d7475726e7374696c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ryangjchandler/laravel-cloudflare-turnstile)

This packages provides an API integrating Laravel with [Cloudflare's Turnstile](https://www.cloudflare.com/en-gb/application-services/products/turnstile/) product.

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require ryangjchandler/laravel-cloudflare-turnstile
```

You should then add the following configuration values to your `config/services.php` file:

```
return [

    // ...,

    'turnstile' => [
        'key' => env('TURNSTILE_SITE_KEY'),
        'secret' => env('TURNSTILE_SECRET_KEY'),
    ],

];
```

Create your Turnstile keys through Cloudflare and add them to your `.env` file.

```
TURNSTILE_SITE_KEY="1x00000000000000000000AA"
TURNSTILE_SECRET_KEY="2x0000000000000000000000000000000AA"

```

Usage
-----

[](#usage)

In your layout file, include the Turnstile scripts using the `` component. This should be added to the `` of your document.

```

        {{ $slot }}

```

Once that's done, you can use the `` component inside of a `` to output the appropriate markup with your site key configured.

```

        Submit

```

To validate the Turnstile response, use the `Turnstile` rule when validating your request.

```
use Illuminate\Validation\Rule;
use RyanChandler\LaravelCloudflareTurnstile\Rules\Turnstile;

public function submit(Request $request)
{
    $request->validate([
        'cf-turnstile-response' => ['required', new Turnstile],
    ]);
}
```

### Customizing the widget

[](#customizing-the-widget)

You can customize the widget by passing attributes to the `` component.

> To learn more about these parameters, refer to [the offical documentation](https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/#configuration-options).

```

        Submit

```

### Livewire support

[](#livewire-support)

This package can also integrate seamlessly with [Livewire](https://livewire.laravel.com).

You can use `wire:model` to bind the Turnstile response to a Livewire property directly.

```

```

#### Multiple widgets with Livewire

[](#multiple-widgets-with-livewire)

If you're using Livewire and need to have multiple widgets on the same page, each widget requires a unique ID.

```

```

The `id` property must match this RegEx: `/^[a-zA-Z_][a-zA-Z0-9_-]*$/`. IDs that do not match the RegEx will trigger an exception.

### Writing tests

[](#writing-tests)

If you wish to write tests for your application that uses Turnstile, you can use the `Turnstile` facade to fake responses.

```
use RyanChandler\LaravelCloudflareTurnstile\Facades\Turnstile;

Turnstile::fake(): // Force a successful response.
Turnstile::fake()->fail(); // Force a failed response.
Turnstile::fake()->expired(); // Force an expired token response.
```

Instead of hardcoding the submitted Turnstile token, you can use the `Turnstile::dummy()` method to generate a dummy token.

```
post('/my-form', [
    'cf-turnstile-response' => Turnstile::dummy(),
])
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ryan Chandler](https://github.com/ryangjchandler)
- [All contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

65

—

FairBetter than 99% of packages

Maintenance89

Actively maintained with recent releases

Popularity60

Solid adoption and visibility

Community29

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~97 days

Recently: every ~35 days

Total

14

Last Release

60d ago

Major Versions

v0.2.0 → v1.0.02023-04-14

v1.1.0 → v2.0.02025-02-26

v2.1.0 → v3.0.02025-11-05

PHP version history (3 changes)v0.1.0PHP ^8.1

v2.0.0PHP ^8.3

v2.0.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/568d485d441c691b0358b9091254a6a671fef8f76b73f28af1180ad568d142b2?d=identicon)[ryangjchandler](/maintainers/ryangjchandler)

---

Top Contributors

[![ryangjchandler](https://avatars.githubusercontent.com/u/41837763?v=4)](https://github.com/ryangjchandler "ryangjchandler (37 commits)")[![kaptk2](https://avatars.githubusercontent.com/u/466052?v=4)](https://github.com/kaptk2 "kaptk2 (15 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")[![choowx](https://avatars.githubusercontent.com/u/63900628?v=4)](https://github.com/choowx "choowx (6 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![aguingand](https://avatars.githubusercontent.com/u/17453506?v=4)](https://github.com/aguingand "aguingand (2 commits)")[![soymgomez](https://avatars.githubusercontent.com/u/6207345?v=4)](https://github.com/soymgomez "soymgomez (1 commits)")[![stevebauman](https://avatars.githubusercontent.com/u/6421846?v=4)](https://github.com/stevebauman "stevebauman (1 commits)")[![200-0K](https://avatars.githubusercontent.com/u/38166228?v=4)](https://github.com/200-0K "200-0K (1 commits)")[![tobz-nz](https://avatars.githubusercontent.com/u/443054?v=4)](https://github.com/tobz-nz "tobz-nz (1 commits)")[![AndrasMa](https://avatars.githubusercontent.com/u/95496855?v=4)](https://github.com/AndrasMa "AndrasMa (1 commits)")[![brunogaspar](https://avatars.githubusercontent.com/u/2285372?v=4)](https://github.com/brunogaspar "brunogaspar (1 commits)")[![Erulezz](https://avatars.githubusercontent.com/u/6772197?v=4)](https://github.com/Erulezz "Erulezz (1 commits)")[![Macsimka](https://avatars.githubusercontent.com/u/5254521?v=4)](https://github.com/Macsimka "Macsimka (1 commits)")[![parkourben99](https://avatars.githubusercontent.com/u/7295774?v=4)](https://github.com/parkourben99 "parkourben99 (1 commits)")[![q--](https://avatars.githubusercontent.com/u/2470175?v=4)](https://github.com/q-- "q-- (1 commits)")

---

Tags

laravelryangjchandlerlaravel-cloudflare-turnstile

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ryangjchandler-laravel-cloudflare-turnstile/health.svg)

```
[![Health](https://phpackages.com/badges/ryangjchandler-laravel-cloudflare-turnstile/health.svg)](https://phpackages.com/packages/ryangjchandler-laravel-cloudflare-turnstile)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)[dutchcodingcompany/filament-socialite

Social login for Filament through Laravel Socialite

213914.9k9](/packages/dutchcodingcompany-filament-socialite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
