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

ActiveLibrary[Security](/categories/security)

salihkiraz/lumen-captcha
========================

captcha for lumen

1.7(5y ago)06MITPHPPHP &gt;=5.4

Since Nov 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/salihkiraz/lumen-captcha)[ Packagist](https://packagist.org/packages/salihkiraz/lumen-captcha)[ RSS](/packages/salihkiraz-lumen-captcha/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (5)Versions (9)Used By (0)

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

[](#captcha-for-lumen)

本项目修改自 [Captcha for Laravel 5](https://github.com/mewebstudio/captcha).

预览效果图
-----

[](#预览效果图)

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

安装
--

[](#安装)

- 项目必须启用缓存才能使用，因为验证码和验证码绑定的uuid都是保存在缓存的。 project's `composer.json`.

```
composer require aishan/lumen-captcha
```

or

```
{
    "require": {
        "laravel/lumen-framework": "5.3.*",
        "aishan/lumen-captcha": "v1.3"
    },
    "minimum-stability": "dev"
}
```

使用
--

[](#使用)

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

```
    //验证码
    $app->register(Aishan\LumenCaptcha\CaptchaServiceProvider::class);
    class_alias('Aishan\LumenCaptcha\Facades\Captcha','Captcha');
```

配置
--

[](#配置)

在`bootstrap/app.php`中可以配置各种自定义类型的验证码属性： 更多详细配置请查看

```
/**
 * captcha配置
 */
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',
            'blur'   =>0,//模糊度
            'sharpen'   =>0,//锐化
            'contrast'   =>0,//反差
            'fontColors'=>['#339900','#ff3300','#9966ff','#3333ff'],//字体颜色
        ],
    ]
]);
```

当然，也可以不配置，默认就是default的样式，验证码有效时间5分钟。

使用范例
----

[](#使用范例)

因为lumen一般写的都是无状态的API，所以此处验证码的图片必须绑定一个uuid，获取图片验证码时，先获取验证码url地址和uuid，然后在验证时，提交验证码和uuid一并验证码。

### 生成验证码

[](#生成验证码)

获取验证码信息：

```
{站点域名}/captchaInfo/{type?}

```

其中`type`就是在配置文件中定义的验证码类型（如果你定义了的话），当然也可以不指定`type`，则默认为`default`，返回信息：

```
{
  "code": "10000",
  "msg": "success",
  "sub_code": "",
  "sub_msg": "",
  "result": {
    "captchaUrl": "{站点域名}/captcha/default/fc1d7d7f-3d8c-652a-5e92-90e9822740ad",
    "captchaUuid": "fc1d7d7f-3d8c-652a-5e92-90e9822740ad"
  }
}
```

`captchaUrl`为验证码图片地址，`captchaUuid`为绑定验证码图片的uuid。

#### 验证验证码

[](#验证验证码)

在请求中将验证码的值和uuid随着你的post请求一起发到服务端，在接收参数的地方做验证即可：

```
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

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 64.3% 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 ~200 days

Recently: every ~350 days

Total

8

Last Release

2055d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/251de906d1bd4de4859a3ce9a717c065040ca2c90329c471429d127fc6dd3c68?d=identicon)[salihkiraz](/maintainers/salihkiraz)

---

Top Contributors

[![aishan](https://avatars.githubusercontent.com/u/5790302?v=4)](https://github.com/aishan "aishan (9 commits)")[![salihkiraz](https://avatars.githubusercontent.com/u/7440402?v=4)](https://github.com/salihkiraz "salihkiraz (5 commits)")

---

Tags

lumen Captchalumen SecurityCaptcha for api

### Embed Badge

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

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

###  Alternatives

[mews/captcha

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

2.6k5.5M84](/packages/mews-captcha)[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)[aishan/lumen-captcha

captcha for lumen

118.5k](/packages/aishan-lumen-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

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

captcha for lumen

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

PHPackages © 2026

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