olcx / nb-captcha
captcha package for nbframework
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/olcx/nb-captcha
Requires
- nbcx/framework: dev-master
This package is not auto-updated.
Last update: 2025-10-05 12:50:22 UTC
README
依赖nbframework框架的图形验证码类库
安装
composer require olcx/nb-captcha
##使用
###在控制器里输出验证码
public function index($id = "") {
$captcha = new Captcha([
// 验证码字符集合
'codeSet' => '123456789',
// 验证码字体大小(px)
'fontSize' => 35,
// 是否画混淆曲线
'useCurve' => false,
// 验证码图片高度
'imageH' => 80,
// 验证码图片宽度
'imageW' => 320,
// 验证码位数
'length' => 5,
// 验证成功后是否重置
'reset' => true
]);
$captcha->show($id);
}
控制器里验证
使用TP5的内置验证功能即可
$this->validate($data,[
'captcha|验证码'=>'require|captcha'
]);
或者手动验证
if(!captcha_check($captcha)){
//验证失败
};