PHPackages                             fab120/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. fab120/laravel-cloudflare-turnstile

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

fab120/laravel-cloudflare-turnstile
===================================

A simple package to help integrate Cloudflare Turnstile. Based on ryangjchandler/laravel-cloudflare-turnstile

v3.0.1(4mo ago)0155↓50%MITPHPPHP ^8.2

Since Jan 11Pushed 4mo agoCompare

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

READMEChangelog (1)Dependencies (15)Versions (2)Used By (0)

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/#configurations).

```

        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

40

—

FairBetter than 88% of packages

Maintenance77

Regular maintenance activity

Popularity14

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

127d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bee6fac3ff235d06469b2a8a3afa880ec3e48807f520fa2b98fb9f8a761bcc16?d=identicon)[fab120](/maintainers/fab120)

---

Top Contributors

[![ryangjchandler](https://avatars.githubusercontent.com/u/41837763?v=4)](https://github.com/ryangjchandler "ryangjchandler (35 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] (9 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 (2 commits)")[![parkourben99](https://avatars.githubusercontent.com/u/7295774?v=4)](https://github.com/parkourben99 "parkourben99 (1 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)")[![fab120](https://avatars.githubusercontent.com/u/293368?v=4)](https://github.com/fab120 "fab120 (1 commits)")[![Macsimka](https://avatars.githubusercontent.com/u/5254521?v=4)](https://github.com/Macsimka "Macsimka (1 commits)")

---

Tags

laravelryangjchandlerlaravel-cloudflare-turnstile

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[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)

PHPackages © 2026

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