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

ActivePackage[Security](/categories/security)

fractal512/captcha
==================

Very simple Laravel 5 stateless captcha package.

v1.0.1(5y ago)012MITPHPPHP ^5.6|^7.2|^8.0

Since Jan 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/fractal512/captcha)[ Packagist](https://packagist.org/packages/fractal512/captcha)[ Docs](https://github.com/fractal512/captcha)[ RSS](/packages/fractal512-captcha/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Simple Captcha for Laravel 5+
=============================

[](#simple-captcha-for-laravel-5)

A very simple stateless captcha for [Laravel 5+](http://www.laravel.com/). Basically it's a simple Laravel package wrapper for my old captcha script written a long time ago.

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

[](#installation)

The Captcha can be installed via [Composer](http://getcomposer.org) by requiring the `fractal512/captcha` package and setting the `minimum-stability` to `dev` (required for Laravel 5) in your project's `composer.json`.

```
{
    "require": {
        "laravel/framework": "5.0.*",
        "fractal512/captcha": "^1.0"
    },
    "minimum-stability": "dev"
}
```

Then update your packages with `composer update` or install with `composer install`.

Or require this package with composer:

```
composer require fractal512/captcha

```

In Windows, you'll need to include the GD2 DLL `php_gd2.dll` in php.ini. And you also need include `php_fileinfo.dll` and `php_mbstring.dll` to fit the requirements of `fractal512/captcha`'s dependencies.

Registration in Laravel
-----------------------

[](#registration-in-laravel)

No need in versions with auto discovery (Laravel 5.5+). Register the Captcha Service Provider in the `providers` key in `config/app.php`.

```
    'providers' => [
        // ...
        'Fractal512\Captcha\CaptchaServiceProvider',
    ]
```

for Laravel 5.1+

```
    'providers' => [
        // ...
        Fractal512\Captcha\CaptchaServiceProvider::class,
    ]
```

Register facade for the captcha package in the `aliases` key in `config/app.php`.

```
    'aliases' => [
        // ...
        'Captcha' => 'Fractal512\Captcha\Facades\Captcha',
    ]
```

for Laravel 5.1+

```
    'aliases' => [
        // ...
        'Captcha' => Fractal512\Captcha\Facades\Captcha::class,
    ]
```

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

[](#configuration)

Publish the package `config.php` file to apply your own settings.

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

or run (Laravel 8+)

```
$ php artisan vendor:publish
```

then enter the number of the `Fractal512\Captcha\CaptchaServiceProvider` service provider.

Contents of the file `config/captcha.php`:

```
return [
    'characters' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
    'expire' => 300,
    'attempts' => 10,
    'default' => [],
    'numbers' => [
        'characters' => '0123456789'
    ],
    'letters' => [
        'characters' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    ],
    'uppercase' => [
        'characters' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    ],
    'lowercase' => [
        'characters' => 'abcdefghijklmnopqrstuvwxyz'
    ]
];
```

Configuration options:

- `characters` - set of characters used by captcha (available presets: `default`, `numbers`, `letters`, `uppercase`, `lowercase`);
- `expire` - captcha expiration time in seconds;
- `attempts` - number of attempts per minute to refresh the captcha image.

Additional options may be included:

- `fontsDirectory` - the fully qualified path without trailing slash to custom fonts directory;
- `fontFile` - custom TTF font file name located in `fontsDirectory`;
- `captchaDirectory` - the fully qualified path without trailing slash to custom directory storing captcha files.

Usage Example
-------------

[](#usage-example)

```
    // base_path() . "/routes/web.php"
    Route::any('captcha-example', function() {
        if (request()->getMethod() == 'POST') {
            $rules = ['captcha' => 'required|captcha'];
            $validator = validator()->make(request()->all(), $rules);
            if ($validator->fails()) {
                echo 'Verification failed!';
            } else {
                echo 'Verification passed!';
            }
        }

        $form = '';
        $form .= '';
        $form .= '';
        $form .= captcha_img('default', ['id' => 'captcha-img']);
        $form .= 'Refresh';
        $form .= '';
        $form .= '';
        $form .= 'Check captcha';
        $form .= '';
        return $form;
    });
```

Helpers and Facade
------------------

[](#helpers-and-facade)

### Return Image

[](#return-image)

```
captcha();
```

or using facade

```
Captcha::create();
```

### Return URL

[](#return-url)

```
captcha_src();
```

or using facade

```
Captcha::src('default');
```

### Return HTML

[](#return-html)

```
captcha_img();
```

or using facade

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

To use other configurations
---------------------------

[](#to-use-other-configurations)

```
captcha_img('numbers');

Captcha::img('uppercase');
```

etc.

Links
-----

[](#links)

- Wrapper scaffold was taken from [Captcha for Laravel 5/6/7](https://github.com/mewebstudio/captcha)

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Every ~6 days

Total

2

Last Release

1965d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/733562df7e4a3214a62bb9e4a2c52e2d52dc2355a3d2f61463f0c09d7a39d945?d=identicon)[fractal512](/maintainers/fractal512)

---

Top Contributors

[![fractal512](https://avatars.githubusercontent.com/u/5672875?v=4)](https://github.com/fractal512 "fractal512 (9 commits)")

---

Tags

captchalaravel5 Securitylaravel5 Captcha

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mews/captcha

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

2.6k5.7M88](/packages/mews-captcha)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)

PHPackages © 2026

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