ruiorz/captcha

Captcha library for PHP

Installs: 243

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/ruiorz/captcha

v1.0.3 2024-07-01 10:58 UTC

This package is auto-updated.

Last update: 2025-12-29 03:54:55 UTC


README

A simple captcha library for PHP

Installation

Require this package with composer:

composer require ruiorz/captcha

Usage

# 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())

Configuration

# 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());

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT