php-captcha / captcha
php 图形验证码
1.0
2017-03-22 08:18 UTC
Requires
- php: >=5.5.0
- predis/predis: ~1.1
This package is not auto-updated.
Last update: 2024-09-20 20:42:12 UTC
README
php 图形验证码,需要 GD 扩展。
需要
Predis
安装
composer.json
require: {
"php-captcha/captcha": "~1.0"
}
示例
-
使用 base64 字符串
use Captcha\CaptchaManager $redisClient = ...; $identity = ...; $captcha = new CaptchaManager($redisClient); $base64ImageString = $captcha->createBase64ImageCaptcha($identity); $response = ...; $response->setBody($base64ImageString); return $response;
-
使用 content-type:image/png
use Captcha\CaptchaManager $redisClient = ...; $identity = ...; $captcha = new CaptchaManager($redisClient); $captcha->createStreamImageCaptcha($identity); $response = ...; $response->headers->add([Content-type' => 'image/png']); return $response;