ruiorz/captcha

PHP 验证码库

v1.0.3 2024-07-01 10:58 UTC

This package is auto-updated.

Last update: 2024-10-01 00:09:25 UTC


README

PHP 简单验证码库

安装

使用 composer 安装此包

composer require ruiorz/captcha

使用

# click captcha:
$captcha = new \Ruiorz\Captcha\Click\ClickCaptcha();
$result = $captcha->draw();

# or math captcha:
$captcha = new \Ruiorz\Captcha\Math\MathCaptcha();
$result = $captcha->draw();

# result:
print_r($result->getCaptchaData())
print_r($result->getImageByte())
print_r($result->getImageBase64())

配置

# click captcha:
$config = new \Ruiorz\Captcha\Click\ClickCaptchaConfig();
$config->setFontPath('src/Click/fonts/msyh.ttc');
$config->setImagePath('src/Click/images/3.jpg');
$config->setVerifyLength(3);
$result = (new \Ruiorz\Captcha\Click\ClickCaptcha($config))->draw();
print_r($result->getCaptchaData());

# or math captcha:
$config = new \Ruiorz\Captcha\Math\MathCaptchaConfig();
$config->setFontPath('src/Math/fonts/Bitsumishi.ttf');
$result = (new \Ruiorz\Captcha\Math\MathCaptcha($config))->draw();
print_r($result->getCaptchaData());

贡献

欢迎提交拉取请求。对于重大更改,请先创建一个问题来讨论您希望进行哪些更改。

请确保根据需要更新测试。

许可

MIT