PHPackages                             shetabit/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. shetabit/captcha

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shetabit/captcha
================

Laravel 5 CAPTCHA Integration Package

v1.2(9y ago)3591PHPPHP &gt;=5.4

Since Aug 4Pushed 7y ago3 watchersCompare

[ Source](https://github.com/shetabit/captcha)[ Packagist](https://packagist.org/packages/shetabit/captcha)[ Docs](https://github.com/hamog/captcha)[ RSS](/packages/shetabit-captcha/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

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

[](#laravel-captcha)

This packages works with multiple drivers, and you can create custom drivers if there are not available in the current drivers list (below list).

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

[](#laravel-captcha-1)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/dc4da43b019062b1976ad2fc1e4ee5e889ab5e755bc7e01d709498e4768a615a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73686574616269742f636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/shetabit/captcha)[![Quality Score](https://camo.githubusercontent.com/f26ad0a61830d240f50b7d2f9765464d13165a72cd189e7d429b3349cc5e7460/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f73686574616269742f636170746368612e7376673f6c6162656c3d436f64652532305175616c697479267374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/shetabit/captcha)

This is a Laravel Package for captcha Integration. This package supports `Laravel 5.4+`.

> This packages works with multiple drivers, and you can create custom drivers if there are not available in the [current drivers list](#list-of-available-drivers) (below list).

List of contents
================

[](#list-of-contents)

- [Available drivers](#list-of-available-drivers)
- [Install](#install)
- [Configure](#configure)
- [How to use](#how-to-use)
    - [Add captcha in forms](#add-captcha-in-forms)
    - [Validation](#validation)
    - [Create custom drivers](#create-custom-drivers)
- [Change log](#change-log)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

List of available drivers
=========================

[](#list-of-available-drivers)

- Simple : a simple image captcha.
- Others are under way.

> you can create your own custom driver if not exists in the list , read the `Create custom drivers` section.

Install
-------

[](#install)

Via Composer

```
$ composer require shetabit/captcha
```

Configure
---------

[](#configure)

If you are using `Laravel 5.5` or higher then you don't need to add the provider and alias.

In your `config/app.php` file add these two lines.

```
# In your providers array.
'providers' => [
    ...
    Shetabit\Captcha\Provider\CaptchaServiceProvider::class,
],

# In your aliases array.
'aliases' => [
    ...
    'Payment' => Shetabit\Captcha\Facade\Captcha::class,
],
```

then run `php artisan vendor:publish` to publish `config/captcha.php` file in your config directory.

In the config file you can set the `default driver` to use for all your payments. But you can also change the driver at runtime.

Choose what gateway you would like to use in your application. Then make that as default driver so that you don't have to specify that everywhere. But, you can also use multiple gateways in a project.

```
// Eg. if you want to use simple. (simple is the driver's name)
'default' => 'simple',
```

Then see the configs in the drivers array.

```
'drivers' => [
    'simple' => [
        'middleware' => ['web'], // middleware
        'route' => 'captcha', // route name
        'characters' => 'ABCDEFGHIKJLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789',
        'width'  => 230,
        'height' => 70,
        'foregroundColors' => ['2980b9','2E9FFF','FF1166','000000','22EE99'],
        'backgroundColor' => '#FFF',
        'letterSpacing' => 6,
        'fontFamily' => resource_path('views/vendor/captchaSimpleDriver/assets/fonts/DroidSerif.ttf'),
        'fontSize' => 30,
        'length' => [4, 6],
        'scratches' => [5, 8],
        'sensitive' => false,
        'sessionKey' => 'captcha',
    ],
    ...
]
```

How to use
----------

[](#how-to-use)

you have 2 steps to go

- add captcha in forms
- add validation

#### Add captcha in forms

[](#add-captcha-in-forms)

In your code, use it like the below:

```

...

{!! captcha() !!}

...

```

if you use `simple` driver, you can change the styles and UI easily, just have a look on `resources/views/vendor/captchaSimpleDriver.blade.php`

#### Validation

[](#validation)

in order to validate forms wich use captcha, you can use `captcha` validation role.

The below example shows every thing you need to know about captcha validation:

```
...

$request->validate([
    'email' => 'required|email',
    'password' => 'required|string',
    'captcha' => 'required|captcha',
]);

...
```

#### Create custom drivers:

[](#create-custom-drivers)

First you have to add the name of your driver, in the drivers array and also you can specify any config parameters you want.

```
'drivers' => [
    'simple' => [...],
    'my_driver' => [
        ... # Your Config Params here.
    ]
]
```

Now you have to create a Driver Map Class that will be used to pay invoices. In your driver, You just have to extend `Shetabit\Captcha\Abstracts\Driver`.

Ex. You created a class : `App\Packages\CaptchaDriver\MyDriver`.

```
namespace App\Packages\CaptchaDriver;

use Illuminate\Support\ServiceProvider;
use Shetabit\Captcha\Abstracts\Driver;

class MyDriver extends Driver
{
    protected $serviceProvider;

    /**
     * Driver settings.
     *
     * @var object
     */
    protected $settings;

    public function __construct(ServiceProvider $serviceProvider, $settings)
    {
        $this->serviceProvider = $serviceProvider;
        $this->settings = (object) $settings;
    }

    /**
        you must write your captcha generation
        logic in the below method.
    **/
    public function generate()
    {
        ...

        // create captcha view and return it
        return View::make('yourCustomDriverView');
    }

    /**
        you must write your captcha verification
        logic in the below method.
    **/
    public function verify($token = null)
    {
        ...

        $storedToken = ...

        if (empty($this->settings->sensitive)) {
            $storedToken = mb_strtolower($storedToken);
            $token = mb_strtolower($token);
        }

        return $token == $storedToken;
    }

}
```

Once you create that class you have to specify it in the `captcha.php` config file `map` section.

```
'map' => [
    ...
    'my_driver' => App\Packages\CaptchaDriver\MyDriver::class,
]
```

**Note:-** You have to make sure that the key of the `map` array is identical to the key of the `drivers` array.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Hashem Moghaddari](https://github.com/hamog)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92% 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 ~1 days

Total

2

Last Release

3565d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dbffd65b893ed400216ab503ee3901f943fe225804e9d5aa3502dab0837ae201?d=identicon)[khanzadimahdi](/maintainers/khanzadimahdi)

![](https://www.gravatar.com/avatar/9d73b855df70ba50a46d879126a3f32fb173d12ca3e778e0a72b7398cbef8a26?d=identicon)[shetabit](/maintainers/shetabit)

---

Top Contributors

[![hamog](https://avatars.githubusercontent.com/u/11465084?v=4)](https://github.com/hamog "hamog (23 commits)")[![khanzadimahdi](https://avatars.githubusercontent.com/u/6291970?v=4)](https://github.com/khanzadimahdi "khanzadimahdi (2 commits)")

---

Tags

captchacaptcha-generatorlaravel-captchasimple-laravel-captchacaptchalaravel5 Captchalaravel5.2

### Embed Badge

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

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

###  Alternatives

[bonecms/laravel-captcha

Captcha integration for Laravel

76138.4k](/packages/bonecms-laravel-captcha)[pixelopen/cloudflare-turnstile-bundle

A simple package to help integrate Cloudflare Turnstile on Symfony.

31205.8k3](/packages/pixelopen-cloudflare-turnstile-bundle)[webman/captcha

Captcha generator

1484.2k25](/packages/webman-captcha)[isszz/rotate-captcha

Rotate image captcha

801.7k](/packages/isszz-rotate-captcha)[haruncpi/laravel-simple-captcha

A laravel simple captcha package

1128.3k](/packages/haruncpi-laravel-simple-captcha)[lubosdz/yii2-captcha-extended

Extended captcha code generator for Yii2 framework with configurable obfuscation level

1117.4k](/packages/lubosdz-yii2-captcha-extended)

PHPackages © 2026

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