library ank
Simple and customizable captcha generation library, runs on PHP >= 5.3.
vaibhavpandeyvpz/ank
Simple and customizable captcha generation library, runs on PHP >= 5.3.
- Thursday, February 2, 2017
- by vaibhavpandeyvpz
- Repository
- 1 Watchers
- 1 Stars
- 6 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 3 Versions
- 0 % Grown
vaibhavpandeyvpz/ank
Simple and customizable captcha generation library, runs on PHP >= 5.3., (*1)
Ank: अंक
(Number), (*2)
![Code Coverage][code-coverage-image]
![Latest Version][latest-version-image]
![Downloads][downloads-image]
![PHP Version][php-version-image]
![License][license-image], (*3)
, (*4)
, (*5)
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., (*6)