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

ActivePackage

imgk/captcha
============

Laravel 5 &amp; 6 &amp; 7 Captcha Package

v1.0.34(6y ago)015MITPHPPHP ^7.2

Since May 16Pushed 6y agoCompare

[ Source](https://github.com/WebGameLinux/laravel-cap)[ Packagist](https://packagist.org/packages/imgk/captcha)[ Docs](https://github.com/WebGameLinux/laravel-cap)[ RSS](/packages/imgk-captcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (9)Used By (0)

Captcha for Laravel 5/6/7
=========================

[](#captcha-for-laravel-567)

[![Build Status](https://camo.githubusercontent.com/059f66ef89e51b775dda5384be18537e707ef24cb8a469611b4d4d8bf1b09b7d/68747470733a2f2f7472617669732d63692e6f72672f6d6577656273747564696f2f636170746368612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mewebstudio/captcha) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/fa85500631c0dba36a80e40bc3ea1ef174f1cdd632d08dd47930edb7a01af1e5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6577656273747564696f2f636170746368612f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mewebstudio/captcha/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/e3ecb233b8e0adfa95c856e5c0fcde7db78136a6fe1c17752e85f4f71b186932/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f636170746368612f762f737461626c652e737667)](https://packagist.org/packages/mews/captcha)[![Latest Unstable Version](https://camo.githubusercontent.com/f04f4956555fcebad8b051a77ccbff50abc65dfe3b2e71d89585d1b97a966f98/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f636170746368612f762f756e737461626c652e737667)](https://packagist.org/packages/mews/captcha)[![License](https://camo.githubusercontent.com/5f622a69c4b52e57bb82b9fbe114ca794524e302b15e37f1876f7c258b09a7c2/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f636170746368612f6c6963656e73652e737667)](https://packagist.org/packages/mews/captcha)[![Total Downloads](https://camo.githubusercontent.com/3c3d4e421265d3246f3e42eab65910abc6cb4eb2cb7b4c0ad6b0b124f0eda110/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f636170746368612f646f776e6c6f6164732e737667)](https://packagist.org/packages/mews/captcha)

A simple [Laravel 5/6/7](http://www.laravel.com/) service provider for including the [Captcha for Laravel](https://github.com/WebGameLinux/laravel-cap).

base on [News\\Captcha](https://github.com/mewebstudio/captcha)
===============================================================

[](#base-on-newscaptcha)

change ext-gd to ext-imagick ,new\\captcha is use php gd2 ext

imgk\\captcha use php imagick ext

Preview
-------

[](#preview)

[![Preview](https://camo.githubusercontent.com/5796b984677c086025788097a4f9f89701595234cb98a23c7276c4ea5424c6ef/68747470733a2f2f696d6167652e6962622e636f2f6b5a784d4c6d2f696d6167652e706e67)](https://camo.githubusercontent.com/5796b984677c086025788097a4f9f89701595234cb98a23c7276c4ea5424c6ef/68747470733a2f2f696d6167652e6962622e636f2f6b5a784d4c6d2f696d6167652e706e67)

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

[](#installation)

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

```
{
    "require": {
        "laravel/framework": "5.0.*",
        "mews/captcha": "~2.0"
    },
    "minimum-stability": "dev"
}
```

or

Require this package with composer:

```
composer require imgk/captcha

```

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

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

Usage
-----

[](#usage)

To use the Captcha Service Provider, you must register the provider when bootstrapping your Laravel application. There are essentially two ways to do this.

Find the `providers` key in `config/app.php` and register the Captcha Service Provider.

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

for Laravel 5.1+

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

Find the `aliases` key in `config/app.php`.

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

for Laravel 5.1+

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

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

[](#configuration)

To use your own settings, publish config.

`$ php artisan vendor:publish`

`config/captcha.php`

```
return [
    'default'   => [
        'length'    => 5,
        'width'     => 120,
        'height'    => 36,
        'quality'   => 90,
        'math'      => true, //Enable Math Captcha
    ],
    // ...
];
```

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

[](#example-usage)

### Session Mode:

[](#session-mode)

```
    // [your site path]/Http/routes.php
    Route::any('captcha-test', function() {
        if (request()->getMethod() == 'POST') {
            $rules = ['captcha' => 'required|captcha'];
            $validator = validator()->make(request()->all(), $rules);
            if ($validator->fails()) {
                echo 'Incorrect!';
            } else {
                echo 'Matched :)';
            }
        }

        $form = '';
        $form .= '';
        $form .= '' . captcha_img() . '';
        $form .= '';
        $form .= 'Check';
        $form .= '';
        return $form;
    });
```

### Stateless Mode:

[](#stateless-mode)

You get key and img from this url `http://localhost/captcha/api/math`and verify the captcha using this method:

```
    //key is the one that you got from json response
    $rules = ['captcha' => 'required|captcha_api:'. request('key')];
    $validator = validator()->make(request()->all(), $rules);
    if ($validator->fails()) {
        return response()->json([
            'message' => 'invalid captcha',
        ]);

    } else {
        //do the job
    }
```

Return Image
============

[](#return-image)

```
captcha();
```

or

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

Return URL
==========

[](#return-url)

```
captcha_src();
```

or

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

```

Return HTML
===========

[](#return-html)

```
captcha_img();
```

or

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

To use different configurations
===============================

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

```
captcha_img('flat');

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

etc.

Based on [Intervention Image](https://github.com/Intervention/image)

^\_^

Links
-----

[](#links)

- [Intervention Image](https://github.com/Intervention/image)
- [L5 Captcha on Github](https://github.com/mewebstudio/captcha)
- [L5 Captcha on Packagist](https://packagist.org/packages/mews/captcha)
- [For L4 on Github](https://github.com/mewebstudio/captcha/tree/master-l4)
- [License](http://www.opensource.org/licenses/mit-license.php)
- [Laravel website](http://laravel.com)
- [Laravel Turkiye website](http://www.laravel.gen.tr)
- [MeWebStudio website](http://www.mewebstudio.com)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

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 ~0 days

Total

8

Last Release

2190d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5993db08e3355e449a9ff3f15209f32ac03d32aa0d459fff35c10f78ddf8c830?d=identicon)[WebGameLinux](/maintainers/WebGameLinux)

---

Top Contributors

[![hewei-github](https://avatars.githubusercontent.com/u/12059788?v=4)](https://github.com/hewei-github "hewei-github (11 commits)")

---

Tags

captchalaravel5 Securitylaravel6 Captchalaravel6 Security

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mews/captcha

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

2.6k5.5M84](/packages/mews-captcha)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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