Simple and customizable captcha generation library, runs on PHP >= 5.3.

1.0.1 2017-02-02 02:09 UTC

This package is auto-updated.

Last update: 2024-10-07 00:11:57 UTC


README

Simple and customizable captcha generation library, runs on PHP >= 5.3.

Ank: अंक (Number)

Build status Code Coverage Latest Version Downloads PHP Version License

SensioLabsInsight

Captcha Mathematics Captcha

Install

composer require vaibhavpandeyvpz/ank

Usage

<?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

See LICENSE.md file. Fonts hand-picked from Google Fonts.