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

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

thecoderraman/laravel-captcha
=============================

Captcha verification for Laravel

01PHP

Since Jul 28Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/TheCoderRaman/laravel-captcha)[ Packagist](https://packagist.org/packages/thecoderraman/laravel-captcha)[ RSS](/packages/thecoderraman-laravel-captcha/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

[   ![laravel-captcha](https://camo.githubusercontent.com/8fcd048d3cd96d44ebd81ceb051af39b2714003c91158eb8536f2b826876c484/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230436170746368612e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d746865636f64657272616d616e2532466c61726176656c2d63617074636861267061747465726e3d63697263756974426f617264267374796c653d7374796c655f31266465736372697074696f6e3d436170746368612b766572696669636174696f6e2b666f722b4c61726176656c2e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d323235707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667) ](https://github.com/TheCoderRaman/laravel-captcha)Laravel CAPTCHA Package
=======================

[](#laravel-captcha-package)

 [![license](https://camo.githubusercontent.com/da3552d576e4a46dc16f1d57609b7c96e1adb8bc32be948a84e38b34044a43e9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f546865436f64657252616d616e2f6c61726176656c2d63617074636861)](./LICENSE "license") [![laravel](https://camo.githubusercontent.com/99e7d7d2aab8e2a2488cd774c993527e418cd75da49b4557363b2b368c0993ef/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6f676f2d6c61726176656c2d626c75653f6c6f676f3d6c61726176656c)](https://laravel.com "laravel") [![Latest Version on Packagist](https://camo.githubusercontent.com/a7c0f1c8d79c0b4e165374e3b01e1713d69ea8e7fcf5f828ff878edbb406a564/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746865636f64657272616d616e2f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/TheCoderRaman/laravel-captcha "packagist") [![Total Downloads on Packagist](https://camo.githubusercontent.com/4e8e311f16a7fb4b2240399375a35f4b028f23eb4493e778cdfe77a7aac33333/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746865636f64657272616d616e2f6c61726176656c2d636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thecoderraman/laravel-captcha "downloads")

A flexible and extensible Laravel package for integrating multiple CAPTCHA services including Google reCAPTCHA, hCaptcha, and custom implementations.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Major Technologies](#major-technologies)
- [Structure](#structure)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Environment Variables](#environment-variables)
- [Usage](#usage)
    - [Basic Usage with Facade](#basic-usage-with-facade)
    - [Using Dependency Injection](#using-dependency-injection)
    - [Blade Templates](#blade-templates)
- [Available Drivers](#available-drivers)
    - [1. Google reCAPTCHA v2](#1-google-recaptcha-v2)
    - [2. hCaptcha](#2-hcaptcha)
    - [3. NullCaptcha (Testing/Development)](#3-nullcaptcha-testingdevelopment)
- [Creating Custom Drivers](#creating-custom-drivers)
- [Validation](#validation)
    - [Using Laravel Validation](#using-laravel-validation)
- [Testing](#testing)
- [API Reference](#api-reference)
    - [Captcha Manager](#captcha-manager)
    - [Driver Interface](#driver-interface)
- [Configuration Options](#configuration-options)
- [Troubleshooting](#troubleshooting)
    - [Common Issues](#common-issues)
    - [Debug Mode](#debug-mode)
- [Contributing](#contributing)
- [Repository Branches](#repository-branches)
- [Contributions](#contributions)
- [Pull Requests](#pull-requests)
- [License](#license)
- [Authors](#authors)
- [Code of Conduct](#code-of-conduct)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Support](#support)

Features
--------

[](#features)

- 🔒 Multiple CAPTCHA providers (Google reCAPTCHA v2, hCaptcha)
- 🎯 Easy configuration and setup
- 🔧 Extensible architecture for custom CAPTCHA drivers
- 🧪 Testing-friendly with NullCaptcha driver
- 📦 Laravel package auto-discovery support
- 🎨 Facade support for clean syntax
- ⚡ Configurable global enable/disable functionality

Major Technologies
------------------

[](#major-technologies)

- laravel

Structure
---------

[](#structure)

```
├───config
├───src
└───tests
    ├───Feature
    └───Unit
```

### Requirements

[](#requirements)

- PHP &gt;= 8.3

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

[](#installation)

Install the package via Composer:

```
composer require thecoderraman/laravel-captcha
```

Publish the configuration file:

```
php artisan vendor:publish --provider="TheCoderRaman\Captcha\CaptchaServiceProvider" --tag="config"
```

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

[](#configuration)

The package configuration is located at `config/captcha.php`. Here's the basic structure:

```
 true,

    /*
    |--------------------------------------------------------------------------
    | Default Captcha Handler
    |--------------------------------------------------------------------------
    |
    | Specify which captcha driver to use as default.
    |
    */
    'default' => Captcha::NullCaptcha->value,

    /*
    |--------------------------------------------------------------------------
    | CAPTCHA Driver Class Mappings
    |--------------------------------------------------------------------------
    |
    | Maps enum values to their respective driver class implementations.
    |
    */
    'drivers' => [
        Captcha::Hcaptcha->value => Hcaptcha::class,
        Captcha::ReCaptcha->value => ReCaptcha::class,
        Captcha::NullCaptcha->value => NullCaptcha::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Captcha Configurations
    |--------------------------------------------------------------------------
    |
    | Specific configurations for each CAPTCHA service.
    |
    */
    'captchas' => [
        'null' => [
            'key' => null,
            'secret' => null,
            'url' => null,
        ],
        'hcaptcha' => [
            'key' => env('HCAPTCHA_SITE_KEY'),
            'secret' => env('HCAPTCHA_SECRET_KEY'),
            'url' => 'https://hcaptcha.com/siteverify',
        ],
        'recaptcha' => [
            'key' => env('RECAPTCHA_SITE_KEY'),
            'secret' => env('RECAPTCHA_SECRET_KEY'),
            'url' => 'https://www.google.com/recaptcha/api/siteverify',
        ],
    ],
];
```

Environment Variables
---------------------

[](#environment-variables)

Add the following environment variables to your `.env` file:

```
# hCaptcha Configuration
HCAPTCHA_SITE_KEY=your_hcaptcha_site_key
HCAPTCHA_SECRET_KEY=your_hcaptcha_secret_key

# Google reCAPTCHA Configuration
RECAPTCHA_SITE_KEY=your_recaptcha_site_key
RECAPTCHA_SECRET_KEY=your_recaptcha_secret_key
```

Usage
-----

[](#usage)

### Basic Usage with Facade

[](#basic-usage-with-facade)

```
