visavi / captcha
动画验证码生成器
v3.0.0
2022-03-29 20:37 UTC
Requires
- php: >=8.0.0
- ext-gd: *
README
示例
默认
高级
迷你
方法
- getPhrase - 获取短语
- setWidth - 图像宽度,像素(可选,默认150像素)
- setHeight - 图像高度,像素(可选,默认40像素)
- setTextColor - 文本颜色(可选)
- setBackgroundColor - 背景颜色(可选)
- setFont - 字体路径(可选)
- setWindowWidth - 窗口宽度,像素(可选,默认75像素)
- setPixelPerFrame - 每帧窗口移动,像素(可选,默认15像素)
- setDelayBetweenFrames - 两帧之间时间,毫秒(可选,默认20毫秒)
默认代码
header('Content-Type: image/gif'); $captcha = new CaptchaBuilder(); $_SESSION['captcha'] = $captcha->getPhrase(); return $captcha->render();
高级代码
header('Content-Type: image/gif'); $phrase = new PhraseBuilder(); $phrase = $phrase->getPhrase(5, '1234567890'); $captcha = new CaptchaBuilder($phrase); $captcha ->setWidth(150) ->setHeight(50) ->setTextColor(0, 0, 0) ->setBackgroundColor(255, 255, 255) ->setFont('/path-to-font') ->setWindowWidth(60) ->setPixelPerFrame(15) ->setDelayBetweenFrames(20); $_SESSION['captcha'] = $captcha->getPhrase(); return $captcha->render();
安装
composer require visavi/captcha
许可证
该类是开源软件,许可协议为 MIT 许可协议