承接 jonesshen/think-captcha 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jonesshen/think-captcha

最新稳定版本:v1.0.0

Composer 安装命令:

composer require jonesshen/think-captcha

包简介

captcha package for thinkphp5

README 文档

README

thinkphp5.1 验证码类库

此版本克隆自 top-think/think-captcha

安装

composer require jonesshen/think-captcha

使用

模板里输出验证码

首先要在你应用的路由定义文件中,注册一个验证码路由规则

\think\facade\Route::get('captcha/[:id]', "\\think\\captcha\\CaptchaController@index");

然后就可以在模板文件中使用

<div>{:captcha_img()}</div>

或者

<div><img src="{:captcha_src()}" alt="captcha" /></div>

上面两种的最终效果是一样的

控制器里验证

手动验证(推荐)

if (!captcha_check($captcha)) {
    //验证失败
}

TP5的内置验证功能(此版本captcha规则不再内置)

$this->validate($data, [
    'captcha|验证码' => 'require|captcha'
]);

如需兼容使用,需要在应用公共文件中注册captcha规则

\think\facade\Validate::extend('captcha', function($value, $id = '') {
    return captcha_check($value, $id);
});
\think\facade\Validate::setTypeMsg('captcha', ':attribute错误!');

统计信息

  • 总下载量: 114
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2022-01-06