PHPackages                             ajnorman/turnstile-laravel-middleware - 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. [Security](/categories/security)
4. /
5. ajnorman/turnstile-laravel-middleware

ActiveLibrary[Security](/categories/security)

ajnorman/turnstile-laravel-middleware
=====================================

A package that adds middleware to check for bots using Cloudflare Turnstile

1.0.0-beta.3(1y ago)02MITPHPPHP ^8.2

Since Jan 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/aj-norman/turnstile-laravel-middleware)[ Packagist](https://packagist.org/packages/ajnorman/turnstile-laravel-middleware)[ RSS](/packages/ajnorman-turnstile-laravel-middleware/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

Turnstile Laravel Middleware
============================

[](#turnstile-laravel-middleware)

⚠️ Documentation is incomplete and may be inaccurate. ⚠️
--------------------------------------------------------

[](#️-documentation-is-incomplete-and-may-be-inaccurate-️)

[![Static Badge](https://camo.githubusercontent.com/92f4e2fdcf99c664975c16ed76d9c8215e2c6371b2e96610d09578a72cb3d47a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d7475726e7374696c655f6c61726176656c5f6d6964646c65776172652d6f72616e67653f7374796c653d666c61742d737175617265266c696e6b3d68747470732533412532462532467061636b61676973742e6f72672532467061636b61676573253246616a6e6f726d616e2532467475726e7374696c652d6c61726176656c2d6d6964646c6577617265)](https://camo.githubusercontent.com/92f4e2fdcf99c664975c16ed76d9c8215e2c6371b2e96610d09578a72cb3d47a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d7475726e7374696c655f6c61726176656c5f6d6964646c65776172652d6f72616e67653f7374796c653d666c61742d737175617265266c696e6b3d68747470732533412532462532467061636b61676973742e6f72672532467061636b61676573253246616a6e6f726d616e2532467475726e7374696c652d6c61726176656c2d6d6964646c6577617265)[![Static Badge](https://camo.githubusercontent.com/5e357f22f08acf8619d19233fdf6e8d1af9b8e77625e545f9b7d46409f48d3dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75653f7374796c653d666c61742d737175617265266c696e6b3d68747470732533412532462532466769746875622e636f6d253246616a2d6e6f726d616e2532467475726e7374696c652d6c61726176656c2d6d6964646c6577617265253246626c6f622532466d61696e2532464c4943454e53452e6d64)](https://camo.githubusercontent.com/5e357f22f08acf8619d19233fdf6e8d1af9b8e77625e545f9b7d46409f48d3dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75653f7374796c653d666c61742d737175617265266c696e6b3d68747470732533412532462532466769746875622e636f6d253246616a2d6e6f726d616e2532467475726e7374696c652d6c61726176656c2d6d6964646c6577617265253246626c6f622532466d61696e2532464c4943454e53452e6d64)

---

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)

---

Introduction
------------

[](#introduction)

This package provides a piece middleware for Laravel that integrates with Cloudflare Turnstile to protect your application from unwanted bots.

---

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- Laravel &gt;= 11.x
- A Cloudflare account with Turnstile enabled and a `site_key` and `secret_key` generated. View the [Cloudflare Turnstile documentation](https://developers.cloudflare.com/turnstile) for more information.

---

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

[](#installation)

You can install the package via composer:

```
composer require aj-norman/turnstile-laravel-middleware
```

Add the following environment variables to your `.env` file:

```
CF_TURNSTILE_SITE_KEY=
CF_TURNSTILE_SECRET_KEY=
```

(Optional) Publish the configuration file:

```
php artisan vendor:publish --provider="AJNorman\Turnstile\TurnstileServiceProvider" --tag="config"
```

> If you customize the configuration file, you may need to manually update the `config/turnstile.php` file in the future if the package is updated.

Add `'turnstile' => AJNorman\Turnstile\Middleware\TurnstileMiddleware::class` middleware to the `alias()` array within the `withMiddleware()` method in your `bootstrap/app.php` file:

```
return Application::configure(basePath: dirname(__DIR__))
    //...
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            //...
            'turnstile' => \AJNorman\Turnstile\Middleware\TurnstileMiddleware::class,
        ]);
    })
    //...
    ->create();
```

> The `'turnstile'` key can be changed to any key you prefer.

---

Usage
-----

[](#usage)

You can apply the Turnstile middleware to any route or group of routes by adding `'turnstile'` to the middleware array:

```
Route::post('/protected-route', function () {
    return 'This route is protected by Turnstile!';
})->middleware('turnstile');
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~0 days

Total

3

Last Release

524d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/24577267?v=4)[AJ](/maintainers/aj-norman)[@aj-norman](https://github.com/aj-norman)

---

Top Contributors

[![aj-norman](https://avatars.githubusercontent.com/u/24577267?v=4)](https://github.com/aj-norman "aj-norman (15 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/ajnorman-turnstile-laravel-middleware/health.svg)

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

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)

PHPackages © 2026

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