PHPackages                             achetibi/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. [Security](/categories/security)
4. /
5. achetibi/laravel-captcha

ActivePackage[Security](/categories/security)

achetibi/laravel-captcha
========================

Laravel Captcha Package

1.0.0(1mo ago)06MITPHPPHP ^8.3CI passing

Since Apr 16Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (13)Versions (2)Used By (0)

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

[](#laravel-captcha)

[![Latest Version on Packagist](https://camo.githubusercontent.com/580c00fc5efc599ea45b294a18c651d447ac71dfa65dd186a735875cfa995300/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61636865746962692f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/achetibi/laravel-captcha)[![Total Downloads](https://camo.githubusercontent.com/b6cbc27c49295e562b9342ab8eb2ec04ff7269afc48656a319987a79e8313c94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61636865746962692f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/achetibi/laravel-captcha)[![Tests](https://camo.githubusercontent.com/93b9899b6ae976f01820e30947c147081c80f631a5159ad205b3cd3f856288a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61636865746962692f6c61726176656c2d636170746368612f74657374732e796d6c3f6c6162656c3d7465737473)](https://github.com/achetibi/laravel-captcha/actions)[![License](https://camo.githubusercontent.com/3724c4408242b9be460d152382ec499ff5102303c89d81ba56481c2852c0f7bf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f61636865746962692f6c61726176656c2d63617074636861)](LICENSE.md)

**Laravel Captcha** is a modern, lightweight, and extensible CAPTCHA package for Laravel. It provides a flexible and developer-friendly way to generate and validate CAPTCHA images, with support for multiple drivers and configurations.

> ⚠️ This package is **based primarily on** the excellent [mews/captcha](https://github.com/mewebstudio/captcha) package, with a redesigned architecture, improved testability, and modern Laravel support.

---

🚀 Features
----------

[](#-features)

- Simple and flexible CAPTCHA generation
- Multiple configurations (`default`, `flat`, `mini`, `inverse`, `math`)
- Support for **GD** and **Imagick** drivers
- API-friendly responses (Base64 image output)
- Built-in validation (session &amp; API modes)
- Fully configurable:
    - Length
    - Fonts
    - Colors
    - Backgrounds
    - Effects (blur, sharpen, contrast, etc.)
- Math CAPTCHA support
- Laravel-native integration:
    - Service Provider
    - Facade
    - Helper functions
- Fully tested using Pest

---

📦 Requirements
--------------

[](#-requirements)

- PHP **&gt;= 8.3**
- Laravel **12.x or 13.x**

> ❗ Other Laravel versions are **not supported**

---

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

[](#-installation)

```
composer require achetibi/laravel-captcha
```

---

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

[](#️-configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="LaravelCaptcha\CaptchaServiceProvider"
```

---

🧠 Basic Usage

Generate CAPTCHA (HTML response)

```
captcha();
```

Generate CAPTCHA (API / Base64)

```
captcha('default');
```

Get CAPTCHA image URL

```
captcha_src();
```

Get CAPTCHA HTML image

```
captcha_img('default', ['class' => 'captcha']);
```

Validate CAPTCHA (session-based)

```
captcha_check($value);
```

Validate CAPTCHA (API-based)

```
captcha_api_check($value, $key);
```

Check CAPTCHA status

```
captcha_enabled();
captcha_disabled();
```

---

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

[](#️-configuration-options)

Example configuration:

```
'default' => [
    'length' => 6,
    'width' => 345,
    'height' => 65,
    'quality' => 90,
    'math' => false,
    'expire' => 60,
    'encrypt' => false,
],
```

---

🖼 Available Presets
-------------------

[](#-available-presets)

- default
- flat
- mini
- inverse
- math

---

🖼 Image Drivers
---------------

[](#-image-drivers)

The package supports two image drivers:

- GD (default)
- Imagick

Driver Configuration

```
CAPTCHA_DRIVER=gd
```

or

```
CAPTCHA_DRIVER=imagick
```

### Driver Fallback

[](#driver-fallback)

If imagick is selected but not installed, the package will automatically fallback to GD.

---

🧪 Testing
---------

[](#-testing)

Run the test suite:

```
composer test
```

The package includes:

- Unit tests
- Feature tests
- Driver validation tests (GD / Imagick)
- Exception handling tests
- Helper and facade tests

---

🧱 Architecture
--------------

[](#-architecture)

The package is structured around:

- Captcha core service
- Laravel Service Container binding
- Facade for convenient access
- Global helper functions

---

⚠️ Important Notes
------------------

[](#️-important-notes)

- CAPTCHA is single-use (invalidated after validation)
- Cache is used for expiration handling
- Session is used for standard validation
- API mode does not rely on session

---

🔒 Security
----------

[](#-security)

- Values are hashed using Laravel’s Hash Manager
- Optional encryption using Laravel Crypt
- One-time validation prevents replay attacks

---

📌 Roadmap
---------

[](#-roadmap)

- Multiple configurations
- GD / Imagick support
- API validation
- Full test coverage
- Custom driver support
- WebP / AVIF support
- Rate limiting integration

---

🙏 Credits
---------

[](#-credits)

- [Abderrahim CHETIBI](https://github.com/achetibi)
- [mews/captcha](https://github.com/mewebstudio/captcha)
- [All Contributors](../../contributors)

---

📄 License
---------

[](#-license)

The MIT License (MIT). See [LICENSE.md](LICENSE.md) for full license text.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance89

Actively maintained with recent releases

Popularity6

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

Unknown

Total

1

Last Release

55d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/30299188?v=4)[Abderrahim CHETIBI](/maintainers/achetibi)[@achetibi](https://github.com/achetibi)

---

Top Contributors

[![achetibi](https://avatars.githubusercontent.com/u/30299188?v=4)](https://github.com/achetibi "achetibi (1 commits)")

---

Tags

captchaLaravel Securitylaravel-captcha

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

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

Laravel 5/6/7/8/9/10/11/12 Captcha Package

2.7k5.7M87](/packages/mews-captcha)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9732.3M121](/packages/roots-acorn)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.1k3.4M80](/packages/unisharp-laravel-filemanager)[flarum/core

Delightfully simple forum software.

261.4M2.2k](/packages/flarum-core)[api-platform/laravel

API Platform support for Laravel

59156.3k10](/packages/api-platform-laravel)

PHPackages © 2026

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