承接 ddr/filament-captcha 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ddr/filament-captcha

Composer 安装命令:

composer require ddr/filament-captcha

包简介

Multi-provider captcha integration for Filament forms (hCaptcha, reCAPTCHA v2/v3, Turnstile)

README 文档

README

Latest Version Total Downloads GitHub Tests Action Status GitHub Code Style Action Status License

Multi-provider captcha integration for Filament forms, supporting hCaptcha, reCAPTCHA v2, reCAPTCHA v3, and Cloudflare Turnstile.

Features

  • 🔒 Multiple captcha providers (hCaptcha, reCAPTCHA v2, reCAPTCHA v3, Turnstile)
  • 🎨 Seamless integration with Filament forms
  • ⚙️ Driver-based architecture for easy extension
  • 🧪 Comprehensive test coverage
  • 📦 Compatible with Filament v3, v4 and v5
  • 🔧 Development mode support

Requirements

  • PHP ^8.2
  • Laravel 11, 12 or 13
  • Filament 3, 4 or 5

Installation

composer require ddr/filament-captcha

Publish the configuration file (optional):

php artisan vendor:publish --tag="captcha-config"

Configuration

Add the following environment variables to your .env file based on your chosen provider:

hCaptcha

CAPTCHA_DRIVER=hcaptcha
HCAPTCHA_SITEKEY=your-site-key
HCAPTCHA_SECRET=your-secret-key

Get your keys at hCaptcha Dashboard.

Google reCAPTCHA v2

CAPTCHA_DRIVER=recaptcha_v2
RECAPTCHA_V2_SITEKEY=your-site-key
RECAPTCHA_V2_SECRET=your-secret-key

Get your keys at Google reCAPTCHA Admin Console.

Google reCAPTCHA v3

CAPTCHA_DRIVER=recaptcha_v3
RECAPTCHA_V3_SITEKEY=your-site-key
RECAPTCHA_V3_SECRET=your-secret-key
RECAPTCHA_V3_SCORE=0.5

Get your keys at Google reCAPTCHA Admin Console.

The RECAPTCHA_V3_SCORE determines the minimum score required to pass validation (0.0 - 1.0, default: 0.5).

Cloudflare Turnstile

CAPTCHA_DRIVER=turnstile
TURNSTILE_SITEKEY=your-site-key
TURNSTILE_SECRET=your-secret-key

Get your keys at Cloudflare Turnstile Dashboard.

Usage

In Filament Forms

use Ddr\FilamentCaptcha\Forms\Components\Captcha;

public function form(Form $form): Form
{
    return $form
        ->schema([
            // ... other fields
            Captcha::make('captcha'),
        ]);
}

Specifying a Driver

You can override the default driver:

Captcha::make('captcha')->driver('recaptcha_v2')

Custom Login Page

Create a custom login page extending Filament's base login:

<?php

namespace App\Filament\Pages\Auth;

use Ddr\FilamentCaptcha\Forms\Components\Captcha;
use Filament\Auth\Pages\Login as BaseLogin;
use Filament\Schemas\Schema;

class Login extends BaseLogin
{
    public function form(Schema $schema): Schema
    {
        return $schema
            ->components([
                $this->getEmailFormComponent(),
                $this->getPasswordFormComponent(),
                $this->getRememberFormComponent(),
                Captcha::make('captcha')->hiddenLabel(),
            ]);
    }
}

Then register it in your AdminPanelProvider:

->login(\App\Filament\Pages\Auth\Login::class)

Validation Rule

You can use the captcha validation rule independently:

use Ddr\FilamentCaptcha\Rules\Captcha;

$request->validate([
    'captcha' => ['required', new Captcha('hcaptcha')],
]);

Development Mode

The captcha field adapts its behavior based on which credentials are configured:

  • No site key configured: the field is completely hidden and validation is skipped, allowing forms to work without any captcha setup.
  • Site key configured, no secret key: the widget is displayed but server-side verification is skipped. Useful for testing the UI locally.
  • Both keys configured: full captcha flow with server-side verification (production).

Customization

Publishing Assets

You can publish and customize the package's configuration, views, and translations:

# Publish configuration file
php artisan vendor:publish --tag="captcha-config"

# Publish views
php artisan vendor:publish --tag="filament-captcha-views"

# Publish translations
php artisan vendor:publish --tag="filament-captcha-translations"

Customizing Views

After publishing views, they will be available in resources/views/vendor/filament-captcha/. You can customize:

  • Driver-specific widgets: resources/views/vendor/filament-captcha/drivers/*.blade.php
  • Main component: resources/views/vendor/filament-captcha/forms/components/captcha.blade.php

Laravel will automatically use your published views instead of the package defaults.

Customizing Configuration

After publishing the config file, you can customize driver settings, verify URLs, and other options in config/captcha.php.

Provider Comparison

Feature hCaptcha reCAPTCHA v2 reCAPTCHA v3 Turnstile
Privacy-focused
User interaction ✅ Checkbox ✅ Checkbox ❌ Invisible ⚡ Smart
Score-based
Free tier ✅ Unlimited ✅ 1M/month ✅ 1M/month ✅ Unlimited
GDPR compliant ⚠️ Requires config ⚠️ Requires config

Testing

composer test          # Run tests
composer lint          # Check code style
composer lint:fix      # Fix code style
composer analyse       # Run static analysis
composer check         # Run all checks

License

The MIT License (MIT). Please see License File for more information.

ddr/filament-captcha 适用场景与选型建议

ddr/filament-captcha 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.89k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 12 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「recaptcha」 「captcha」 「laravel」 「filament」 「hcaptcha」 「turnstile」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ddr/filament-captcha 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ddr/filament-captcha 我们能提供哪些服务?
定制开发 / 二次开发

基于 ddr/filament-captcha 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-23