简单可定制的验证码生成库,支持 PHP >= 5.3。

1.0.1 2017-02-02 02:09 UTC

This package is auto-updated.

Last update: 2024-09-07 00:02:07 UTC


README

简单可定制的验证码生成库,支持 PHP >= 5.3。

Ank: अंक (数字)

Build status Code Coverage Latest Version Downloads PHP Version License

SensioLabsInsight

Captcha Mathematics Captcha

安装

composer require vaibhavpandeyvpz/ank

用法

<?php

/**
 * @desc Create an instance of desired captcha generator. Ank\CaptchaGenerator will generate a random captcha code
 *      while Ank\MathCaptchaGenerator will generate basic mathematics calculations for user to solve.
 */
$captcha = new Ank\CaptchaGenerator();
// or
$captcha = new Ank\MathCaptchaGenerator();

// Generate a captcha image and output the image to user-agent
header('Content-Type: image/png');
echo $captcha->getCaptcha();

// To verify user input at a later time
if ($captcha->isValid($_POST['captcha'])) {
    // ... captcha is valid
}

/*
 * @desc You can also customize look and feel of your image, change font, background or text color and lot more.
 */
$image = $captcha->getCaptcha()
    ->setBackgroundColor('#000')
    ->setForegroundColor('#efefef')
    ->setFont(Ank\CaptchaImage::FONT_ACME)
    ->setSize(256, 96)
    ->setQuality(100);

echo $image;

许可证

请参阅 LICENSE.md 文件。字体来自 Google Fonts