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

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

youngyezi/captcha
=================

Captcha for Lumen，Lumen 验证码

v6.0(6y ago)731.0k↑16.7%5[1 issues](https://github.com/Youngyezi/captcha/issues)MITPHPPHP ^7.2

Since Dec 25Pushed 6y ago1 watchersCompare

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

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

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

[](#captcha-for-lumen)

基于 [Captcha for Laravel 5](https://github.com/mewebstudio/captcha "Captcha for Laravel 5") 修改而来的

> A simple [Laravel 5](http://www.laravel.com/) service provider for including the [Captcha for Laravel 5](https://github.com/mewebstudio/captcha).

update
------

[](#update)

支持了lumen 6x

源于
--

[](#源于)

Captcha for Laravel 5 作者很久没有更新了，同时 Captcha 在 Lumen 有很多错误

由此我基于原 Captcha 包进行了一些错误修复来集成 Lumen 。 同时删除了一些个人觉得太过冗余的东西，让使用更加方便和自由

安装
--

[](#安装)

```
composer require youngyezi/captcha

```

使用
--

[](#使用)

> 新版的包已经删除了 session 支持，完全交给业务自由选择存储方式
>
> 个人觉得这样更方便来解耦业务，尤其 Lumen 大多时候用来做 Api 开发，并不需要开启 Session 服务

### 注册服务 `bootstrap\app.php`

[](#注册服务-bootstrapappphp)

```
$app->register(Youngyezi\Captcha\CaptchaServiceProvider::class);

// 添加别名
$app->alias('captcha', 'Youngyezi\Captcha\CaptchaServiceProvider');

```

### 配置文件

[](#配置文件)

复制 `config/captcha.php` 至 项目 `config` 文件下

For Example
-----------

[](#for-example)

### 验证码生成

[](#验证码生成)

```
//  创建验证码
//  配置文件 key($config)
//  返回 验证码 captcha 和相关 key
$data = app('captcha')->create();

//  自定义储存 key （如 redis ，session 等）

....

//  返回验证码图片 img

```

### 验证码校验

[](#验证码校验)

```
// 通过 code 和 key 来校验
$captcha = $request->input('captcha');

// 获取自定义存储的 key 值
$key = { ... };

if(app('captcha')->check($captcha, $key) === false) {
	   //校验失败
}

```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

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

Total

4

Last Release

2200d ago

Major Versions

1.1 → 2.02018-12-25

2.0 → 6.0.x-dev2020-05-07

PHP version history (2 changes)1.1PHP &gt;=5.6.4

6.0.x-devPHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/522583582e8966e792fec3527a1ef4619e772dc9b3e362d193de8924c8d05b19?d=identicon)[Youngyezi](/maintainers/Youngyezi)

---

Top Contributors

[![Youngyezi](https://avatars.githubusercontent.com/u/8175293?v=4)](https://github.com/Youngyezi "Youngyezi (14 commits)")

### Embed Badge

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

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

###  Alternatives

[pearl/lumen-request-validate

Lumen doesn't have form request validator seperatly. This package helps developers to segregate the validation layer from the controller to a separate dedicated class

45390.3k2](/packages/pearl-lumen-request-validate)

PHPackages © 2026

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