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

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

straylightagency/laravel-captcha
================================

Laravel package with prepared drivers to enable captcha services like Google Recaptcha or Cloudflare Turnstile using Validator Rules.

09PHP

Since May 15Pushed 2mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#laravel-captcha)

Adds Captcha verification functionality to Laravel based on services API.

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

[](#installation)

Require this package with composer.

```
composer require straylightagency/laravel-captcha
```

### Laravel without auto-discovery:

[](#laravel-without-auto-discovery)

If you do not use auto-discovery, add the `CaptchaServiceProvider` to the providers array in `bootstrap/providers.php` :

```
\Straylightagency\LaravelCaptcha\CaptchaServiceProvider::class,
```

Use this artisan command to publish the captcha.php file inside your config folder :

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

You must set the site key and secret key based on the service you want to use inside your `.env` file :

```
## select your drive here : fake, recaptcha, recaptcha-enterprise or turnstile
CAPTCHA_DRIVER=recaptcha-enterprise

## if you use Google ReCaptcha or ReCaptcha Enterprise :
GOOGLE_RECAPTCHA_SITE_KEY="FAK3S1T3K3Y21AI3C9S3VJZ-V65M1SMWLGEPX4SB"
GOOGLE_RECAPTCHA_API_KEY="FAK3AP1K3YXEFG7V2EV1HK1-RGGGU817475938X1O0"
GOOGLE_RECAPTCHA_PROJECT_ID="project-123456"
GOOGLE_RECAPTCHA_SECRET_KEY="FAK3S3CR3TK3YBQYVMJQYMLT4W57RTFFO0MF38VB"

## if you use Cloudflare Turnstile :
CLOUDFLARE_TURNSTILE_SITE_KEY="FAK3S1T3K3YNPY1AEHI2O6P-6AYWQVLJ8439LG3N"
CLOUDFLARE_TURNSTILE_SECRET_KEY="FAK3S3CR3TK3Y8X1O0T0Q2KBQWLKEDUQYNP6GHE3"
```

In your languages directory, add an extra translation in every `validation.php` language file :

```
'captcha' => 'The captcha is not valid.',
```

Validation
----------

[](#validation)

You can use the `captcha_rule()` helper function directly inside the validation array :

```
$validator = Validator::make( $request->all(), [
    // [...]
    'captcha' => ['required', 'string', captcha_rule()],
] );
```

You can also use the `captcha` rule macro :

```
$validator = Validator::make( $request->all(), [
    // [...]
    'captcha' => ['required|string|captcha'], // works too
] );
```

Use the `->default()` method if you want to use the `required` and `string` macro with the `captcha` rule.

```
$validator = Validator::make( $request->all(), [
    'name' => ['required', 'string'],
    'email' => ['required', 'string', 'email'],
    'content' => ['required', 'string'],
    ...captcha_rule()->default(),
    // parameter $key_name of default() method allow you to edit the field name.
] );
```

Some Verifier needs a script tag inside the `` tag of your HTML page, you can use an helper function to print the right script based on the selected Verifier :

```

    {!! captcha_script() !!}

```

For more information about frontend integration, check the documentation bellow from the API service you want to use.

Requirement
-----------

[](#requirement)

PHP 8.3 or above

See also
--------

[](#see-also)

- [Google ReCaptcha](https://developers.google.com/recaptcha/intro)
- [Google ReCaptcha Enterprise](https://docs.cloud.google.com/recaptcha/docs)
- [Cloudflare Turnstile](https://developers.cloudflare.com/turnstile/)

Credits
-------

[](#credits)

- [Anthony Pauwels](https://github.com/anthonypauwels)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance57

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4163238?v=4)[Anthony Pauwels](/maintainers/anthonypauwels)[@anthonypauwels](https://github.com/anthonypauwels)

---

Top Contributors

[![anthonypauwels](https://avatars.githubusercontent.com/u/4163238?v=4)](https://github.com/anthonypauwels "anthonypauwels (8 commits)")

### Embed Badge

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

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

###  Alternatives

[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)[firemultimedia/mautic-multi-captcha-bundle

This plugin brings Google's reCAPTCHA, hCaptcha, and Cloudflare Turnstile integration to mautic.

141.3k](/packages/firemultimedia-mautic-multi-captcha-bundle)

PHPackages © 2026

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