Fork from yokov/captcha and fix some bug.
$ composer require sobyte/captcha -vvv
$config = [
// 验证码字符类型
'charType' => 'default',
// 验证码长度
'length' => 4,
// 是否是 gif 动态图
'isGif' => false,
// 动图帧率
'gifFps' => 12,
// 图片宽度
'width' => 150,
// 图片高度
'height' => 40,
// 字体文件路径
'fontPath' => '',
// 字体大小
'fontSize' => 24,
];
$builder = new \Sobyte\Captcha\CaptchaBuilder($config);
// 获取验证码字符串
$builder->getChar();
// 生成验证码图片
$builder->build();
-
验证码字符类型
- default: 大小写字母和数字混合
- only_char: 只有大小写字母
- only_number: 只有数字
-
字体文件
-
注:可自定义字体文件,fontPath 配置相应的字体文件路径即可
-
库中内置 9 种字体(fontPath 设置 1-9 可分别指定相应的字体)
字体序号 静态样式 动图 1 2 3 4 5 6 7 8 9 -
MIT