PHPackages                             swjtuhyq/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. swjtuhyq/captcha

ActivePackage[Validation &amp; Sanitization](/categories/validation)

swjtuhyq/captcha
================

Lumen 9 &amp; 10 Captcha Package

2.0.0(2y ago)039MITPHPPHP ^8.1

Since Sep 2Pushed 2y ago1 watchersCompare

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

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

Captcha for Lumen 9/10
======================

[](#captcha-for-lumen-910)

[![Latest Stable Version](https://camo.githubusercontent.com/95981e28c1170def62dc57d8f7e47a8e5c02a33077b4716c82f1e7693d47dd86/68747470733a2f2f706f7365722e707567782e6f72672f73776a74756879712f636170746368612f762f737461626c652e737667)](https://packagist.org/packages/swjtuhyq/captcha)[![Latest Unstable Version](https://camo.githubusercontent.com/2aad50fc51d6e40647c5469a2ac8f0c9e3565193ac9345e85625cf680f883e8c/68747470733a2f2f706f7365722e707567782e6f72672f73776a74756879712f636170746368612f762f756e737461626c652e737667)](https://packagist.org/packages/swjtuhyq/captcha)[![License](https://camo.githubusercontent.com/f6121a88fe98d71d703c0fa1dcea35fb6ee8ed4163657352c3df7bdcb5816ca5/68747470733a2f2f706f7365722e707567782e6f72672f73776a74756879712f636170746368612f6c6963656e73652e737667)](https://packagist.org/packages/swjtuhyq/captcha)[![Total Downloads](https://camo.githubusercontent.com/43fda20d28198037ede7aee97cd76e9e94bde922c2d6909973db03901e687f13/68747470733a2f2f706f7365722e707567782e6f72672f73776a74756879712f636170746368612f646f776e6c6f6164732e737667)](https://packagist.org/packages/swjtuhyq/captcha)

A simple [Lumen 9/10](http://www.laravel.com/) service provider for including the [Captcha for Lumen](https://github.com/swjtuhyq/captcha).

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

[](#installation)

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

```
{
    "require": {
        "laravel/lumen-framework": "^10.0",
        "swjtuhyq/captcha": "~2.0"
    },
    "minimum-stability": "dev"
}
```

or

Require this package with composer:

```
composer require swjtuhyq/captcha

```

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

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 `swjtuhyq/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' => [
        // ...
        'Swjtuhyq\Captcha\CaptchaServiceProvider',
    ]
```

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

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

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

[](#configuration)

To use your own settings, publish config.

`config/captcha.php`

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

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

[](#example-usage)

### 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
    // fix validator
    // $rules = ['captcha' => 'required|captcha_api:'. request('key')];
    $rules = ['captcha' => 'required|captcha_api:'. request('key') . ',math'];
    $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 [Captcha for Laravel 5/6/7/8](https://github.com/mewebstudio/captcha)

^\_^

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/swjtuhyq/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)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

3

Last Release

836d ago

Major Versions

1.0.1 → 2.0.02024-03-19

PHP version history (2 changes)1.0.0PHP ^7.2|^8.0

2.0.0PHP ^8.1

### Community

Maintainers

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

---

Tags

captchaLumen6 Captcha

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mews/captcha

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

2.6k5.8M89](/packages/mews-captcha)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.5M85](/packages/unisharp-laravel-filemanager)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M130](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M193](/packages/laravel-ai)

PHPackages © 2026

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