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

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

yangbx/captcha-lumen
====================

captcha for lumen

1.3.0(6y ago)123.8k10[2 issues](https://github.com/Yangbx/captcha-lumen/issues)MITPHPPHP &gt;=5.4

Since Nov 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Yangbx/captcha-lumen)[ Packagist](https://packagist.org/packages/yangbx/captcha-lumen)[ RSS](/packages/yangbx-captcha-lumen/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (5)Versions (6)Used By (0)

Captcha for Lumen
=================

[](#captcha-for-lumen)

本項目修改 [Captcha for Laravel 5](https://github.com/mewebstudio/captcha) 和 [lumen-captcha](https://github.com/aishan/lumen-captcha)

Requirement
-----------

[](#requirement)

Lumen version &gt;= v5.5

Preview
-------

[](#preview)

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

Install
-------

[](#install)

- 此 Package 必須開啟 Cache 才能使用，因為驗證碼與綁定驗證碼的 uuid 都是保存在 Cache 的。

```
composer require yangbx/captcha-lumen

```

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

[](#how-to-use)

在`bootstrap/app.php`中註冊Captcha Service Provider：

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

Set
---

[](#set)

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

```
/**
 * captcha set
 */
config(['captcha'=>
    [
        'useful_time' => 5, //驗證碼有效時間（分鐘）
        'captcha_characters' => '2346789abcdefghjmnpqrtuxyzABCDEFGHJMNPQRTUXYZ',
        'sensitive' => false, //驗證碼是否判斷大小寫
        'login'   => [ //驗證碼樣式
            'length'    => 4, //驗證碼字數
            'width'     => 120, //圖片寬度
            'height'    => 36, //字體大小和圖片高度
            'angle'     => 10, //字體傾斜度
            'lines'     => 2, //橫線數
            'quality'   => 90, //品質
            'invert'    =>false, //反相
            'bgImage'   =>true, //背景圖
            'bgColor'   =>'#ffffff',
            'fontColors'=>['#339900','#ff3300','#9966ff','#3333ff'],//字體顏色
        ],
    ]
]);
```

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

Example
-------

[](#example)

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

### Generate

[](#generate)

獲得驗證碼：

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

```

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

```
{
  "captchaUrl": "http://{Domain}/captcha/default/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

33

—

LowBetter than 75% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 62.5% 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 ~227 days

Total

5

Last Release

2540d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/362c31a9775595e096e955f4e48db21e8a5c4675832f52f14ca700f1e666a0db?d=identicon)[Yangbx](/maintainers/Yangbx)

---

Top Contributors

[![Yangbx](https://avatars.githubusercontent.com/u/10116313?v=4)](https://github.com/Yangbx "Yangbx (5 commits)")[![leonlokaka](https://avatars.githubusercontent.com/u/7693739?v=4)](https://github.com/leonlokaka "leonlokaka (3 commits)")

---

Tags

captchalumen CaptchaCaptcha for api

### Embed Badge

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

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

###  Alternatives

[unisharp/laravel-filemanager

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

2.2k3.3M74](/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)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)[aishan/lumen-captcha

captcha for lumen

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

PHPackages © 2026

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