dennist12/turnstile-services 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

dennist12/turnstile-services

最新稳定版本:v2.2.0

Composer 安装命令:

composer require dennist12/turnstile-services

包简介

a php library for turnstile service

README 文档

README

A simple Laravel wrapper for integrating Cloudflare Turnstile CAPTCHA verification.

Installation

Install the package via Composer:

composer require dennist12/turnstile-services

Configuration

Publish the configuration file:

php artisan vendor:publish --tag=dennist12/turnstile-config

config/turnstile.php

<?php


return [
    // Default turnstile key
    'key' => env('TURNSTILE_KEY', 'your-default-key'),
];

Usage Example

use Dennist12\Turnstile\TurnstileServices;
use Illuminate\Validation\ValidationException;

// Instantiate the TurnstileServices class
$turnsTile = new TurnstileServices();

// Verify the CAPTCHA response
$response = $turnsTile->verifyCaptcha($this->captcha, request()->ip());

// Handle the response
if ($response['success']) {
    // CAPTCHA verification passed
    // Proceed with login or other logic
} else {
    // CAPTCHA verification failed
    throw ValidationException::withMessages([
        'captcha' => $response['error-codes'],
    ]);
}

Example Responses

✅ Successful Validation

{
  "success": true,
  "challenge_ts": "2022-02-28T15:14:30.096Z",
  "hostname": "example.com",
  "error-codes": [],
  "action": "login",
  "cdata": "sessionid-123456789"
}

❌ Failed Validation

{
  "success": false,
  "error-codes": ["invalid-input-response"]
}

Documentation

For more information on server-side validation with Turnstile, check out the official Cloudflare docs:

👉 Turnstile Server-side Validation

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-11