PHPackages                             haosheng0211/laravel-captcha - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. haosheng0211/laravel-captcha

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

haosheng0211/laravel-captcha
============================

A Laravel package providing unified captcha verification with support for reCAPTCHA, Turnstile, and hCaptcha

v1.0.1(3mo ago)012MITPHPPHP ^8.2CI passing

Since Mar 20Pushed 3mo agoCompare

[ Source](https://github.com/haosheng0211/laravel-captcha)[ Packagist](https://packagist.org/packages/haosheng0211/laravel-captcha)[ Docs](https://github.com/haosheng0211/laravel-captcha)[ RSS](/packages/haosheng0211-laravel-captcha/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (9)Versions (3)Used By (0)

Laravel Captcha
===============

[](#laravel-captcha)

[![Latest Version on Packagist](https://camo.githubusercontent.com/573689fccd67fff5087d4d7e434391e60228831bde1036a6356ac3a8ca9e3a37/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68616f7368656e67303231312f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haosheng0211/laravel-captcha)[![GitHub Tests Action Status](https://camo.githubusercontent.com/00f57d45d95bddae0fe9caeef8a3907e44e88d028b722340261e2eabada3ff5a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68616f7368656e67303231312f6c61726176656c2d636170746368612f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/haosheng0211/laravel-captcha/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/5a72a86948bb7f259b6799d0b81e70bd93b8bca3b2d104b243387de136e50dbb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68616f7368656e67303231312f6c61726176656c2d636170746368612f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/haosheng0211/laravel-captcha/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/866648f01fa6b0d3908b030d9be90ac37024f314d0befed11d7666fbe3081944/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68616f7368656e67303231312f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haosheng0211/laravel-captcha)

A Laravel package that provides a unified API for integrating multiple captcha services, including Google reCAPTCHA (v2 &amp; v3), Cloudflare Turnstile, and hCaptcha. Easily switch between providers with minimal code changes.

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

[](#installation)

You can install the package via composer:

```
composer require haosheng0211/laravel-captcha
```

You can publish the config file with:

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

This is the contents of the published config file:

```
return [

    'enabled' => env('CAPTCHA_ENABLED', true),

    'default' => env('CAPTCHA_DRIVER', 'recaptcha'),

    'providers' => [
        'recaptcha' => [
            'version' => env('RECAPTCHA_VERSION', 'v2'),
            'site_key' => env('RECAPTCHA_SITE_KEY'),
            'secret_key' => env('RECAPTCHA_SECRET_KEY'),
            'score' => 0.5,
        ],
        'turnstile' => [
            'site_key' => env('TURNSTILE_SITE_KEY'),
            'secret_key' => env('TURNSTILE_SECRET_KEY'),
        ],
        'hcaptcha' => [
            'site_key' => env('HCAPTCHA_SITE_KEY'),
            'secret_key' => env('HCAPTCHA_SECRET_KEY'),
        ],
    ],

];
```

Configuration
-------------

[](#configuration)

Add the following environment variables to your `.env` file based on the captcha provider you want to use:

```
# Global settings
CAPTCHA_ENABLED=true
CAPTCHA_DRIVER=recaptcha

# Google reCAPTCHA
RECAPTCHA_VERSION=v2
RECAPTCHA_SITE_KEY=your-site-key
RECAPTCHA_SECRET_KEY=your-secret-key

# Cloudflare Turnstile
TURNSTILE_SITE_KEY=your-site-key
TURNSTILE_SECRET_KEY=your-secret-key

# hCaptcha
HCAPTCHA_SITE_KEY=your-site-key
HCAPTCHA_SECRET_KEY=your-secret-key
```

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use MrJin\Captcha\Facades\Captcha;

// Verify using the default driver
$result = Captcha::verify($request->input('captcha_token'), $request->ip());

// Verify using a specific driver
$result = Captcha::driver('turnstile')->verify($token, $ip);

// Check if captcha is enabled
if (Captcha::isEnabled()) {
    // ...
}
```

### Using the Validation Rule

[](#using-the-validation-rule)

```
use MrJin\Captcha\Rules\CaptchaRule;

$request->validate([
    'captcha_token' => ['required', new CaptchaRule],
]);

// With a specific driver
$request->validate([
    'captcha_token' => ['required', new CaptchaRule('turnstile')],
]);
```

### Supported Drivers

[](#supported-drivers)

DriverProviderVersions`recaptcha`Google reCAPTCHAv2, v3`turnstile`Cloudflare Turnstile-`hcaptcha`hCaptcha-Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Mr.Jin](https://github.com/haosheng0211)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance81

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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

2

Last Release

98d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9288489?v=4)[Haosheng Zou](/maintainers/haosheng)[@Haosheng](https://github.com/Haosheng)

---

Top Contributors

[![haosheng0211](https://avatars.githubusercontent.com/u/45075952?v=4)](https://github.com/haosheng0211 "haosheng0211 (2 commits)")

---

Tags

laravellaravel-captchaMrJin

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/haosheng0211-laravel-captcha/health.svg)

```
[![Health](https://phpackages.com/badges/haosheng0211-laravel-captcha/health.svg)](https://phpackages.com/packages/haosheng0211-laravel-captcha)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k98.0M1.3k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M42](/packages/spatie-laravel-pdf)[spatie/laravel-passkeys

Use passkeys in your Laravel app

470755.5k32](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.9M53](/packages/jeffgreco13-filament-breezy)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)

PHPackages © 2026

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