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

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

lazycaptcha/laravel
===================

Laravel integration for LazyCaptcha — drop-in CAPTCHA protection for forms, with validation rule, middleware, Blade component, and facade.

2.1(1mo ago)022MITPHPPHP ^8.2CI passing

Since Apr 17Pushed 1mo agoCompare

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

READMEChangelog (3)Dependencies (8)Versions (4)Used By (0)

LazyCaptcha for Laravel
=======================

[](#lazycaptcha-for-laravel)

Drop-in [LazyCaptcha](https://github.com/yourusername/lazycaptcha) integration for Laravel apps. Adds a Blade component, validation rule, middleware, and facade — so protecting a form is one line of HTML and one line of validation.

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Latest Stable Version](https://camo.githubusercontent.com/22b9d1a39e74f02a74132adc4c62bd5ca1a0c68a3c30f4fe717accb99596e0e9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c617a79636170746368612f6c61726176656c2e737667)](https://packagist.org/packages/lazycaptcha/laravel)

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

[](#installation)

```
composer require lazycaptcha/laravel
```

The service provider and facade auto-register via Laravel package discovery.

Publish the config (optional):

```
php artisan vendor:publish --tag=lazycaptcha-config
```

Add your keys to `.env`:

```
LAZYCAPTCHA_SITE_KEY=your-site-key-uuid
LAZYCAPTCHA_SECRET_KEY=your-secret-hex
LAZYCAPTCHA_URL=https://your-lazycaptcha-instance.com    # optional, defaults to https://lazycaptcha.com
```

Usage
-----

[](#usage)

### 1. Render the widget in a form

[](#1-render-the-widget-in-a-form)

The simplest path — drop the Blade component anywhere:

```

    @csrf

    Send

```

The component reads the site key from your config. You can override per-form:

```

```

Widget preset and width overrides are supported too:

```

```

Color scheme and watermark placement are configurable per-component:

```

```

Available `color-scheme` values: `default`, `ocean`, `forest`, `sunset`, `graphite`. Available `watermark-position` values: `footer-right`, `footer-left`, `top-right`, `top-left`. Available `watermark-display` values: `full`, `badge`, `icon` (paid plans only — free always renders `full`).

Set defaults globally via `.env`:

```
LAZYCAPTCHA_COLOR_SCHEME=ocean
LAZYCAPTCHA_WATERMARK_POSITION=footer-right
LAZYCAPTCHA_WATERMARK_DISPLAY=icon
```

> **Newsletter widgets** are intentionally minimal: regardless of any `type` you pass, they always serve a `press_hold` challenge and render in the most compact box. This is enforced both server-side (`ChallengeManager`) and client-side (widget JS).

There's also a Blade directive if you prefer:

```
@lazycaptcha
{{-- or --}}
@lazycaptcha('SITE_KEY')
```

### 2. Verify on submit — pick one of three styles

[](#2-verify-on-submit--pick-one-of-three-styles)

#### Option A: Validation rule (recommended)

[](#option-a-validation-rule-recommended)

```
public function store(Request $request)
{
    $validated = $request->validate([
        'email' => 'required|email',
        'message' => 'required|string|max:1000',
        'lazycaptcha-token' => 'required|lazycaptcha',
    ]);

    // ... process the validated data
}
```

For Laravel 10+ rule objects with a minimum risk score:

```
use LazyCaptcha\Laravel\Rules\ValidLazyCaptcha;

$request->validate([
    'lazycaptcha-token' => ['required', new ValidLazyCaptcha(minScore: 0.5)],
]);
```

#### Option B: Middleware

[](#option-b-middleware)

Register the alias in `bootstrap/app.php`:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'lazycaptcha' => \LazyCaptcha\Laravel\Http\Middleware\VerifyLazyCaptcha::class,
    ]);
})
```

Apply it to routes:

```
Route::post('/contact', [ContactController::class, 'store'])
    ->middleware('lazycaptcha');
```

The verification result is attached to the request:

```
$result = $request->attributes->get('lazycaptcha');
// ['success' => true, 'score' => 0.87, 'hostname' => '...', 'challenge_ts' => '...']
```

#### Option C: Facade

[](#option-c-facade)

```
use LazyCaptcha;

if (! LazyCaptcha::check($request->input('lazycaptcha-token'), $request->ip())) {
    abort(422, 'Captcha failed');
}

// Or get the full response
$result = LazyCaptcha::verify($request->input('lazycaptcha-token'), $request->ip());
if (! $result['success']) {
    return back()->withErrors(['captcha' => $result['error']]);
}
```

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

[](#configuration)

Full config reference (`config/lazycaptcha.php`):

KeyEnvDefaultDescription`site_key``LAZYCAPTCHA_SITE_KEY`—**Required.** Public site key.`secret_key``LAZYCAPTCHA_SECRET_KEY`—**Required.** Secret key (server-side only).`base_url``LAZYCAPTCHA_URL``https://lazycaptcha.com`Your LazyCaptcha instance URL.`timeout``LAZYCAPTCHA_TIMEOUT``5`HTTP timeout in seconds.`type``LAZYCAPTCHA_TYPE``auto`Default challenge type.`theme``LAZYCAPTCHA_THEME``auto`Widget theme.`widget``LAZYCAPTCHA_WIDGET``standard`Widget preset. `newsletter` stays intentionally skinny.`width``LAZYCAPTCHA_WIDTH`â€”Optional width override. The hosted widget caps widths at `500px`.`token_field`—`lazycaptcha-token`Form field name (don't change unless you know why).`send_remote_ip`—`true`Forward client IP to verification API.Testing
-------

[](#testing)

When testing forms that use the captcha, you'll typically want to skip verification. Mock the facade:

```
use LazyCaptcha\Laravel\Facades\LazyCaptcha;

LazyCaptcha::shouldReceive('check')->andReturn(true);
LazyCaptcha::shouldReceive('verify')->andReturn(['success' => true, 'score' => 1.0]);

$this->post('/contact', ['email' => 'a@b.c', 'message' => 'hi', 'lazycaptcha-token' => 'fake'])
    ->assertRedirect('/');
```

Compatibility
-------------

[](#compatibility)

- Laravel 10, 11, 12, 13
- PHP 8.2+

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance92

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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 ~6 days

Total

3

Last Release

41d ago

Major Versions

1.0 → 2.02026-04-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b733b3a3e7ab710c0321c8f7798da8393fd89d96651b8a1322e80f8199ef739?d=identicon)[lazycaptcha](/maintainers/lazycaptcha)

---

Top Contributors

[![lazycaptcha](https://avatars.githubusercontent.com/u/276395808?v=4)](https://github.com/lazycaptcha "lazycaptcha (16 commits)")

---

Tags

laravellaravel-frameworkphplaravelcaptchaform validationbot-protectionlazycaptcha

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76318.2M110](/packages/laravel-mcp)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9732.3M121](/packages/roots-acorn)[moonshine/moonshine

Laravel administration panel

1.3k239.9k72](/packages/moonshine-moonshine)[illuminate/auth

The Illuminate Auth package.

9327.9M1.2k](/packages/illuminate-auth)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

719160.4k12](/packages/tallstackui-tallstackui)

PHPackages © 2026

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