PHPackages                             dev-3bdulrahman/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. dev-3bdulrahman/laravel-captcha

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

dev-3bdulrahman/laravel-captcha
===============================

A simple, standalone Laravel CAPTCHA package with multiple styles and difficulty levels

v2.1.2(6mo ago)1323MITPHPPHP ^8.0|^8.1|^8.2|^8.3CI failing

Since Oct 1Pushed 6mo agoCompare

[ Source](https://github.com/Dev-3bdulrahman/Laravel-Captcha)[ Packagist](https://packagist.org/packages/dev-3bdulrahman/laravel-captcha)[ Docs](https://github.com/Dev-3bdulrahman/Laravel-Captcha)[ RSS](/packages/dev-3bdulrahman-laravel-captcha/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (8)Used By (0)

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

[](#laravel-captcha)

 [![Laravel Captcha Banner](./captcha-banner.svg)](./captcha-banner.svg)

 [![Latest Version on Packagist](https://camo.githubusercontent.com/5f477124d111f6467a036d66d8cfd57c61e0949db9d0ef9bb5e46ebdda7b5df5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465762d336264756c7261686d616e2f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dev-3bdulrahman/laravel-captcha) [![Total Downloads](https://camo.githubusercontent.com/531767ccd1df687135c19ae7e0c04e7de3c64c8901a9f0cba42e1bdcc21a1cf0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465762d336264756c7261686d616e2f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dev-3bdulrahman/laravel-captcha) [![License](https://camo.githubusercontent.com/e4bc61049b84866522b0a839fc487239dd1b3b8a53090ded5f91dd2dc2209be0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465762d336264756c7261686d616e2f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dev-3bdulrahman/laravel-captcha)

A simple, standalone Laravel CAPTCHA package with multiple styles and difficulty levels. No external dependencies or third-party services required!

✨ Features
----------

[](#-features)

- 🎨 **Multiple Captcha Types**: Image, Math, Text, and Slider captchas
- 🎯 **Three Difficulty Levels**: Easy, Medium, and Hard
- 🎭 **Multiple Visual Styles**: Default, Modern, Minimal, and Colorful
- 🔒 **Fully Standalone**: No Google reCAPTCHA or external services
- 🚀 **Easy Integration**: Simple Blade components and validation rules
- 📱 **Responsive Design**: Works perfectly on all devices
- ⚡ **Lightweight**: Minimal dependencies, maximum performance
- 🎨 **Customizable**: Extensive configuration options
- 🖼️ **SVG Support**: No GD Library required when using SVG format

📋 Requirements
--------------

[](#-requirements)

- PHP 8.0 or higher
- Laravel 9.x, 10.x, or 11.x
- GD Library (optional - only required for PNG image captcha)

> **Note**: Starting from version 2.0, you can use SVG captcha which doesn't require GD Library!

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require dev-3bdulrahman/laravel-captcha
```

Publish the configuration file:

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

Publish the assets (CSS, JS):

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

Optionally, publish the views for customization:

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

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Add Captcha to Your Form

[](#1-add-captcha-to-your-form)

```

    @csrf

    @include('captcha::captcha', ['type' => 'image', 'difficulty' => 'medium'])

    Submit

```

### 2. Validate the Captcha

[](#2-validate-the-captcha)

```
use Illuminate\Http\Request;

public function submit(Request $request)
{
    $request->validate([
        'captcha' => 'required|captcha',
        // other validation rules
    ]);

    // Process your form
}
```

That's it! 🎉

📚 Usage
-------

[](#-usage)

### Captcha Types

[](#captcha-types)

#### Image Captcha (Default)

[](#image-captcha-default)

```
@include('captcha::captcha', [
    'type' => 'image',
    'difficulty' => 'medium',
    'style' => 'modern'
])
```

#### Math Captcha

[](#math-captcha)

```
@include('captcha::captcha', [
    'type' => 'math',
    'difficulty' => 'easy'
])
```

#### Text Captcha

[](#text-captcha)

```
@include('captcha::captcha', [
    'type' => 'text',
    'difficulty' => 'hard'
])
```

#### Slider Captcha

[](#slider-captcha)

```
@include('captcha::captcha', [
    'type' => 'slider',
    'difficulty' => 'medium'
])
```

### Difficulty Levels

[](#difficulty-levels)

- **Easy**: Simple challenges, fewer characters/operations
- **Medium**: Moderate complexity (default)
- **Hard**: Complex challenges with more noise and difficulty

### Visual Styles

[](#visual-styles)

- **default**: Classic captcha appearance
- **modern**: Sleek, contemporary design
- **minimal**: Clean and simple
- **colorful**: Vibrant and eye-catching

### Using SVG Captcha (No GD Library Required)

[](#using-svg-captcha-no-gd-library-required)

To use SVG captcha instead of PNG (which requires GD Library), update your configuration:

```
// config/captcha.php
'image' => [
    'use_svg' => true, // Enable SVG format
    // ... other settings
],
```

Or set the environment variable:

```
CAPTCHA_USE_SVG=true
```

Then use it normally:

```
@include('captcha::captcha', [
    'type' => 'image',
    'difficulty' => 'medium'
])
```

### Using the Facade

[](#using-the-facade)

```
use Dev3bdulrahman\LaravelCaptcha\Facades\Captcha;

// Generate captcha
$data = Captcha::generate('image', 'medium');

// Verify captcha
$isValid = Captcha::verify($input, 'image');

// Refresh captcha
Captcha::refresh('image');

// Get captcha data
$data = Captcha::getData('image');
```

### Manual Validation

[](#manual-validation)

```
use Dev3bdulrahman\LaravelCaptcha\Facades\Captcha;

if (Captcha::verify($request->input('captcha'), 'image')) {
    // Captcha is valid
} else {
    // Captcha is invalid
}
```

### API Routes

[](#api-routes)

The package automatically registers these routes:

- `GET /captcha/generate/{type?}` - Generate captcha data
- `GET /captcha/image/{type?}` - Get captcha image
- `POST /captcha/verify` - Verify captcha
- `GET /captcha/refresh` - Refresh captcha

⚙️ Configuration
----------------

[](#️-configuration)

The configuration file `config/captcha.php` allows you to customize:

```
return [
    // Default captcha type
    'default' => 'image',

    // Default difficulty level
    'difficulty' => 'medium',

    // Session key for storing captcha
    'session_key' => 'laravel_captcha',

    // Expiration time in minutes
    'expire' => 5,

    // Image captcha settings
    'image' => [
        'width' => 200,
        'height' => 60,
        'length' => [
            'easy' => 4,
            'medium' => 5,
            'hard' => 6,
        ],
        // ... more settings
    ],

    // Math captcha settings
    'math' => [
        'operators' => [
            'easy' => ['+', '-'],
            'medium' => ['+', '-', '*'],
            'hard' => ['+', '-', '*', '/'],
        ],
        // ... more settings
    ],

    // ... other settings
];
```

🎨 Customization
---------------

[](#-customization)

### Custom Questions for Text Captcha

[](#custom-questions-for-text-captcha)

Edit `config/captcha.php`:

```
'text' => [
    'questions' => [
        'easy' => [
            'Your question?' => 'answer',
            // Add more questions
        ],
    ],
],
```

### Custom Styling

[](#custom-styling)

Publish the views and modify the CSS:

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

Then edit the files in `resources/views/vendor/captcha/`.

🧪 Testing
---------

[](#-testing)

```
composer test
```

📖 Examples
----------

[](#-examples)

### Example 1: Contact Form

[](#example-1-contact-form)

```

    @csrf

    @include('captcha::captcha', ['type' => 'math', 'difficulty' => 'easy'])

    @error('captcha')
        {{ $message }}
    @enderror

    Send Message

```

### Example 2: Registration Form

[](#example-2-registration-form)

```

    @csrf

    @include('captcha::captcha', [
        'type' => 'image',
        'difficulty' => 'medium',
        'style' => 'modern'
    ])

    Register

```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

📝 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

👨‍💻 Author
----------

[](#‍-author)

**Abdulrahman Mehesan**

- Website:
- GitHub: [@Dev-3bdulrahman](https://github.com/Dev-3bdulrahman)

🙏 Support
---------

[](#-support)

If you find this package helpful, please consider giving it a ⭐ on [GitHub](https://github.com/Dev-3bdulrahman/Laravel-Captcha)!

📸 Screenshots
-------------

[](#-screenshots)

### Image Captcha

[](#image-captcha)

[![Image Captcha](./screenshots/image-captcha.png)](./screenshots/image-captcha.png)

### Math Captcha

[](#math-captcha-1)

[![Math Captcha](./screenshots/math-captcha.png)](./screenshots/math-captcha.png)

### Text Captcha

[](#text-captcha-1)

[![Text Captcha](./screenshots/text-captcha.png)](./screenshots/text-captcha.png)

### Slider Captcha

[](#slider-captcha-1)

[![Slider Captcha](./screenshots/slider-captcha.png)](./screenshots/slider-captcha.png)

---

Made with ❤️ by [Abdulrahman Mehesan](https://3bdulrahman.com/)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance67

Regular maintenance activity

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.6% 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

7

Last Release

192d ago

Major Versions

v1.0.1 → v2.0.12025-10-03

PHP version history (2 changes)v1.0.0PHP ^8.0|^8.1|^8.2|^8.3

2.1.0PHP ^8.0|^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b5c1a6e40ee93671d5a15810d4f35be20545aeca3c06ee62b4293fcf936d8f5c?d=identicon)[Dev-3bdulrahman](/maintainers/Dev-3bdulrahman)

---

Top Contributors

[![Dev-3bdulrahman](https://avatars.githubusercontent.com/u/132305340?v=4)](https://github.com/Dev-3bdulrahman "Dev-3bdulrahman (5 commits)")[![itajory](https://avatars.githubusercontent.com/u/100446192?v=4)](https://github.com/itajory "itajory (4 commits)")

---

Tags

laravel-packagelaravelvalidationsecuritycaptchaspam protection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dev-3bdulrahman-laravel-captcha/health.svg)

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

###  Alternatives

[olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel. Uses zxcvbn-php by @bjeavons.

28311.1k1](/packages/olssonm-l5-zxcvbn)[rebelinblue/laravel-zxcvbn

Service provider to use the zxcvbn project by @dropbox in Laravel 5.4 and above

1160.4k](/packages/rebelinblue-laravel-zxcvbn)

PHPackages © 2026

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