PHPackages                             cann/laravel-vcode - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. cann/laravel-vcode

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

cann/laravel-vcode
==================

Laravel Sms Verification

v2.1(2y ago)12012MITPHP

Since Jul 1Pushed 2y ago2 watchersCompare

[ Source](https://github.com/cnny/laravel-vcode)[ Packagist](https://packagist.org/packages/cann/laravel-vcode)[ RSS](/packages/cann-laravel-vcode/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

laravel-vcode
=============

[](#laravel-vcode)

便捷的验证码发送工具，目前支持基于\[easysms\] 的短信验证码

### 安装

[](#安装)

```
composer require cann/laravel-vcode

```

### 发布资源

[](#发布资源)

```
php artisan vendor:publish --provider="Cann\Vcode\VcodeServiceProvider"

```

### 数据库迁移

[](#数据库迁移)

```
php artisan migrate

```

### 参数配置

[](#参数配置)

`config/easysms.php`: 短信服务商配置

`config/vcode.php`: 验证码相关配置

### 使用

[](#使用)

#### 定义环境变量

[](#定义环境变量)

修改 `.env` 加入相关配置（以腾讯云短信通道为例）：

```
SMS_QCLOUD_SECRET_ID=
SMS_QCLOUD_SECRET_KEY=
SMS_QCLOUD_REGION=
SMS_QCLOUD_APP_ID=
SMS_QCLOUD_VCODE_TPL=
SMS_QCLOUD_VCODE_TPL_INTL=
SMS_SIGN_NAME=高灯科技
```

#### 发送验证码

[](#发送验证码)

该工具提供了统一的接口进行验证码发送：

##### 请求

[](#请求)

`POST`:`{host}/{prefix}/vcode`

#### 请求参数

[](#请求参数)

字段必填类型详细描述channel否STRING验证码发送渠道
 `sms`: 短信验证码 (默认)
 `email`: 邮箱验证码 (暂不支持)scene是STRING发送场景
 `config/vcode.channels.{channel}.scenes` 中定义
 注：不同场景短信冷却时间不共享，验证码不通用mobile是STRING发送目标，字段名可在 `config/vcode.channels.{channel}.field` 修改captcha\_key否STRING图形验证码 Key
 注：当触发图形验证码时，该值必填captcha\_code否STRING图形验证码
 注：当触发图形验证码时，该值必填#### 响应参数

[](#响应参数)

字段类型详细描述codeINT响应码，可在 `config/vcode.responses` 修改messageSTRING响应消息，可在 `config/vcode.responses` 修改dataARRAY响应数据#### 响应成功样例

[](#响应成功样例)

```
{
    "code": 0,
    "message": "发送成功",
    "data": {
        "seconds": 60
    }
}
```

or

```
{
    "code": -1,
    "message": "你的动作太快了，请在 57 秒后重试",
    "data": {
        "seconds": 57
    }
}
```

or

```
{
    "code": -101,
    "message": "请输入图形验证码",
    "data": {
        "captcha_api": "http://yocann.cn/api/captcha"
    }
}
```

#### 验证码校验

[](#验证码校验)

- 使用 Validator 验证，可在 `vcode` 参数上加上 `verify_code` 验证器进行验证，`verify_vcode` 会自动读取请求中的 `channel` `scene` `mobile` `vcode` 参数进行校验
- 使用 `verify_vcode(string $scene, string $mobile, string $vcode, string $channel)` 方法进行校验

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.1% 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 ~643 days

Total

3

Last Release

951d ago

Major Versions

v1.0 → v2.02023-12-07

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76446?v=4)[cann](/maintainers/cann)[@cann](https://github.com/cann)

---

Top Contributors

[![cnny](https://avatars.githubusercontent.com/u/17918962?v=4)](https://github.com/cnny "cnny (18 commits)")[![silverd](https://avatars.githubusercontent.com/u/1514608?v=4)](https://github.com/silverd "silverd (13 commits)")

### Embed Badge

![Health badge](/badges/cann-laravel-vcode/health.svg)

```
[![Health](https://phpackages.com/badges/cann-laravel-vcode/health.svg)](https://phpackages.com/packages/cann-laravel-vcode)
```

###  Alternatives

[james.xue/login-captcha

laravel-admin 登录验证码

3625.9k](/packages/jamesxue-login-captcha)[manzhouya/auth-attempts

Add captcha and login attempts for laravel-admin

142.1k](/packages/manzhouya-auth-attempts)[iamtong/laravel-admin-login-check-safe

登录添加验证码，后台用户锁定，错误次数过多锁定，密码强制修改，添加密码修改记录，登录日志

122.6k](/packages/iamtong-laravel-admin-login-check-safe)[overtrue/laravel-qcloud-federation-token

QCloud COS FederationToken generator for Laravel.

1710.0k](/packages/overtrue-laravel-qcloud-federation-token)

PHPackages © 2026

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