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

ActiveLibrary

tridiamond/captcha-lumen5
=========================

captcha for lumen

v1.0.3(7y ago)210.2k↓100%[1 issues](https://github.com/TriDiamond/captcha-lumen5/issues)MITPHPPHP &gt;=5.4

Since May 30Pushed 7y agoCompare

[ Source](https://github.com/TriDiamond/captcha-lumen5)[ Packagist](https://packagist.org/packages/tridiamond/captcha-lumen5)[ RSS](/packages/tridiamond-captcha-lumen5/feed)WikiDiscussions master Synced 1mo ago

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

Captcha for Lumen5
==================

[](#captcha-for-lumen5)

本項目修改 [Captcha for Laravel 5](https://github.com/mewebstudio/captcha) 和 [lumen-captcha](https://github.com/aishan/lumen-captcha) 加上了lumen 5.5 支持, 也修复了一些导致不能用的bug

Preview
-------

[](#preview)

[![Preview](https://camo.githubusercontent.com/e5ebfe735c8c3845df743219a60cb26c43754c66b6547dce56f8e82c64e8b261/687474703a2f2f692e696d6775722e636f6d2f485974723734342e706e67)](https://camo.githubusercontent.com/e5ebfe735c8c3845df743219a60cb26c43754c66b6547dce56f8e82c64e8b261/687474703a2f2f692e696d6775722e636f6d2f485974723734342e706e67)

Install
-------

[](#install)

- 此 Package 必须开启 Cache 才能使用，应为验证码是保存在cache里面。

```
composer require tridiamond/captcha-lumen5

```

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

[](#how-to-use)

在`bootstrap/app.php`中注册Captcha Service Provider：

```
    $app->register(TriDiamond\CaptchaLumen5\CaptchaServiceProvider::class);
    class_alias('TriDiamond\CaptchaLumen5\Facades\Captcha','Captcha');
```

Set
---

[](#set)

在`bootstrap/app.php`中可以設定各種自定義類型的驗證碼屬性，更多詳細設定請查看 [Captcha for Laravel 5](https://github.com/mewebstudio/captcha)

```
    'characters' => '2346789abcdefghjmnpqrtuxyzABCDEFGHJMNPQRTUXYZ',

    'useful_time' => 5, //驗證碼有效時間（分鐘）

    'login'   => [ //驗證碼樣式
        'length'    => 4, //驗證碼字數
        'width'     => 100, //圖片寬度
        'height'    => 44, //字體大小和圖片高度
        'angle'     => 10, //字體傾斜度
        'lines'     => 2, //橫線數
        'quality'   => 90, //品質
        'invert'    =>false, //反相
        'bgImage'   =>true, //背景圖
        'bgColor'   =>'#ffffff',
        'fontColors'=>['#339900','#ff3300','#9966ff','#3333ff'],//字體顏色
    ],

    'flat'   => [
        'length'    => 6,
        'width'     => 160,
        'height'    => 46,
        'quality'   => 90,
        'lines'     => 6,
        'bgImage'   => false,
        'bgColor'   => '#ecf2f4',
        'fontColors'=> ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'],
        'contrast'  => -5,
    ],

    'mini'   => [
        'length'    => 3,
        'width'     => 60,
        'height'    => 32,
    ],

    'inverse'   => [
        'length'    => 5,
        'width'     => 120,
        'height'    => 36,
        'quality'   => 90,
        'sensitive' => true,
        'angle'     => 12,
        'sharpen'   => 10,
        'blur'      => 2,
        'invert'    => true,
        'contrast'  => -5,
    ]
```

如果不配置設定檔，默認就是default，驗證碼有效時限為5分鐘。

Example
-------

[](#example)

因為 Lumen 都是無狀態的 API，所以驗證碼圖片都會綁上一個 UUID，先獲得驗證碼的 UUID 跟圖片的 URL，�驗證時再一併發送驗證碼與 UUID。

### Generate

[](#generate)

獲得驗證碼：

```
{Domain}/captchaInfo/{type?}

```

`type`就是在 config 中定義的 Type，如果不指定`type`，默認為`default`樣式，Response：

```
{
  "captchaUrl": "http://{Domain}/api/captcha-image/login/782fdc90-3406-f2a9-9573-444ea3dc4d5c",
  "captchaUuid": "782fdc90-3406-f2a9-9573-444ea3dc4d5c"
}
```

`captchaUrl`為驗證碼圖片的 URL，`captchaUuid`為綁定驗證碼圖片的uuid。

#### validate

[](#validate)

在發送 Request 時將驗證碼與 UUID 一併送回 Server 端，在接收參數時做驗證即可：

```
public function checkCaptcha(Request $request, $type = 'default',$captchaUuid)
    {
        $this->validate($request,[
            'captcha'=>'required|captcha:'.$captchaUuid
        ]);
        ...
    }
```

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

28

—

LowBetter than 54% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

4

Last Release

2900d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/189c8a188e3b823bf14039c26cfe37ff1eb20075ce540e371db2af8e0e1782f5?d=identicon)[TriDiamond](/maintainers/TriDiamond)

---

Top Contributors

[![bennyxguo](https://avatars.githubusercontent.com/u/24708758?v=4)](https://github.com/bennyxguo "bennyxguo (6 commits)")

---

Tags

capturelaravellumenlumen-packagelumen55captchalumen CaptchaCaptcha for apilumen 5.5

### Embed Badge

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

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

###  Alternatives

[unisharp/laravel-filemanager

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

2.2k3.3M73](/packages/unisharp-laravel-filemanager)[mews/captcha

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

2.6k5.5M84](/packages/mews-captcha)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[yangbx/captcha-lumen

captcha for lumen

123.8k](/packages/yangbx-captcha-lumen)[aishan/lumen-captcha

captcha for lumen

118.5k](/packages/aishan-lumen-captcha)

PHPackages © 2026

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