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

ActiveLibrary

ms41/laravel-captcha13
======================

A Laravel 13 compatible CAPTCHA package

v1.0.0(1mo ago)03↑900%MITPHPPHP ^8.3

Since Apr 5Pushed 1mo agoCompare

[ Source](https://github.com/Muhammad-Shahid41/shahid-laravel-captcha13)[ Packagist](https://packagist.org/packages/ms41/laravel-captcha13)[ RSS](/packages/ms41-laravel-captcha13/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Captcha 13
==================

[](#laravel-captcha-13)

A simple, customizable, and Laravel 13 compatible CAPTCHA package for generating image-based captchas with session-based validation.

This package provides:

- CAPTCHA image generation
- Session-based validation
- Easy Blade integration
- Configurable size, route, colors, and font
- Laravel auto-discovery support

---

Preview
-------

[](#preview)

### Captcha Example

[](#captcha-example)

> Add your preview image(s) here after uploading screenshots to your GitHub repository.

#### Example 1

[](#example-1)

[![Captcha Preview 1](./images-preview/preview1.png)](./images-preview/preview1.png)

#### Example 2

[](#example-2)

[![Captcha Preview 2](./images-preview/preview2.png)](./images-preview/preview2.png)

Requirements
------------

[](#requirements)

PHP 8.3+ Laravel 13+ Installation

Install the package via Composer:
---------------------------------

[](#install-the-package-via-composer)

```
composer require ms41/laravel-captcha13
```

Package Auto-Discovery
----------------------

[](#package-auto-discovery)

The package supports Laravel package auto-discovery.

So after installation, you do not need to manually register the service provider or alias.

Publish Configuration
---------------------

[](#publish-configuration)

### If you want to customize the package configuration, publish the config file:

[](#if-you-want-to-customize-the-package-configuration-publish-the-config-file)

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

This will publish:

config/captcha.php

Basic Usage in Blade
--------------------

[](#basic-usage-in-blade)

You can render the captcha image in any Blade view like this:

```
{!! Captcha::img() !!}
```

Basic Form Example
------------------

[](#basic-form-example)

 @csrf ```

    {!! Captcha::img() !!}

Submit

```

Validation Example (Controller)
-------------------------------

[](#validation-example-controller)

```
 use Illuminate\Http\Request;
 use Shahid\Captcha\Facades\Captcha;

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

    if (!Captcha::validate($request->captcha)) {
        return back()
            ->withErrors(['captcha' => 'Invalid captcha entered.'])
            ->withInput();
    }

    return back()->with('success', 'Captcha verified successfully!');
}
```

Validation Example (Route Closure)
----------------------------------

[](#validation-example-route-closure)

```
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Shahid\Captcha\Facades\Captcha;

Route::get('/captcha-test', function () {
    return view('captcha-test');
});

Route::post('/captcha-test', function (Request $request) {
    $request->validate([
        'captcha' => ['required'],
    ]);

    if (!Captcha::validate($request->captcha)) {
        return back()
            ->withErrors(['captcha' => 'Invalid captcha entered.'])
            ->withInput();
    }

    return back()->with('success', 'Captcha verified successfully!');
})->name('captcha.test.submit');
```

Facade Usage
------------

[](#facade-usage)

### The package provides a facade:

[](#the-package-provides-a-facade)

```
use Shahid\Captcha\Facades\Captcha;
```

Available Methods
-----------------

[](#available-methods)

### Render captcha image HTML

[](#render-captcha-image-html)

```
Captcha::img();
```

Validate captcha input
----------------------

[](#validate-captcha-input)

```
Captcha::validate($request->captcha);
```

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

[](#configuration)

After publishing the config file, you can customize the package using:

config/captcha.php
------------------

[](#configcaptchaphp)

Default Configuration

```
