yolo/captcha
最新稳定版本:v1.0.0
Composer 安装命令:
composer require yolo/captcha
包简介
A php captcha package
README 文档
README
要求
- PHP >= 8.1
- gd2
- mbstring
安装
composer require yolo/captcha
使用
<?php
use Yolo\Captcha\Captcha;
use Yolo\Captcha\Core\CaptchaEngine;
require_once __DIR__ . '/../../vendor/autoload.php';
// Global config
Captcha::setConfig([
'height' => 50,
'width' => 250,
'length' => 6, // only for character engine
'font' => __DIR__ . '/fonts/Arial.ttf',
'fontSize' => 25,
'quality' => 0, // 0-9, No effect now
'backgroundColor' => [255, 255, 255],
'fontColor' => [0, 0, 0], // No effect now
'engine' => CaptchaEngine::CHARACTER, // or CaptchaEngine::SIMPLE_ARITHMETIC
]);
$captcha = new Captcha();
$image = $captcha->createCaptcha();
imagepng($image, __DIR__ . '/captcha.png');
// Set the content type and output the image
//header('Content-Type: image/png');
//imagepng($image);
$captcha->destroyCaptcha($image);
// Get the captcha answer
$answer = $captcha->getCaptchaAnswer();
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-28