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. haosheng0211/laravel-captcha

ActiveLibrary

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

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

v1.0.1(4d ago)03↓100%MITPHPPHP ^8.2CI passing

Since Mar 20Pushed 4d 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 today

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

41

—

FairBetter than 89% of packages

Maintenance99

Actively maintained with recent releases

Popularity4

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

4d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7844510af454731ef9d8d0c8dfe93a227fef3011b409e8a8cd3fb6b903dc81c7?d=identicon)[haosheng](/maintainers/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

[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13662.4k1](/packages/ralphjsmit-laravel-helpers)[basillangevin/laravel-data-json-schemas

Transforms Spatie Data objects into JSON Schemas with built-in validation

136.9k1](/packages/basillangevin-laravel-data-json-schemas)

PHPackages © 2026

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