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 1mo ago

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

24

—

LowBetter than 32% of packages

Maintenance42

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

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

471d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0bcb22ec08d3bfde9ec2ae9c33bf95e7d76961d061360ede2b36d9bc45f829aa?d=identicon)[aj-norman](/maintainers/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-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

264778.4k3](/packages/laravel-cashier-paddle)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[spatie/laravel-export

Create a static site bundle from a Laravel app

646127.9k5](/packages/spatie-laravel-export)[dgtlss/warden

A Laravel package that proactively monitors your dependencies for security vulnerabilities by running automated composer audits and sending notifications via webhooks and email

8745.6k](/packages/dgtlss-warden)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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