定制 ajnorman/turnstile-laravel-middleware 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ajnorman/turnstile-laravel-middleware

最新稳定版本:1.0.0-beta.3

Composer 安装命令:

composer require ajnorman/turnstile-laravel-middleware

包简介

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

README 文档

README

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

Static Badge Static Badge

Table of Contents

Introduction

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

Requirements

  • PHP >= 8.2
  • Laravel >= 11.x
  • A Cloudflare account with Turnstile enabled and a site_key and secret_key generated. View the Cloudflare Turnstile documentation for more information.

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=<your-site-key>
CF_TURNSTILE_SECRET_KEY=<your-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

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');

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固