ruiorz / captcha
PHP 验证码库
v1.0.3
2024-07-01 10:58 UTC
Requires
- php: >=8.1
- ext-gd: *
- ext-mbstring: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.0
Suggests
- ext-xdebug: PHP extension that provides line coverage as well as branch and path coverage.
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());
贡献
欢迎提交拉取请求。对于重大更改,请先创建一个问题来讨论您希望进行哪些更改。
请确保根据需要更新测试。