irooit/hyperf-captcha

A CAPTCHA package for Hyperf Framework

1.0.2 2021-11-25 16:52 UTC

This package is auto-updated.

Last update: 2024-03-25 22:13:49 UTC


README

This is the Captcha component for Hyperf 2.

安装

composer require irooit/hyperf-captcha

发布配置

php bin/hyperf.php vendor:publish irooit/hyperf-captcha

字体文件默认发布到 <root>/storage/fonts 目录。

组件依赖 hyperf-ext/encryption 组件加解密 key,依赖 hyperf/cache 组件暂存使用过的 key,您需要发布这些组件的配置:

php bin/hyperf.php vendor:publish hyperf-ext/encryption
php bin/hyperf.php vendor:publish hyperf/cache

使用

use Hyperf\Utils\ApplicationContext;
use Irooit\Captcha\CaptchaFactory;

$captchaFactory = ApplicationContext::getContainer()->get(CaptchaFactory::class);

// 生成
$captcha = $captchaFactory->make();

// 验证
$captchaFactory->validate($key, $text);

本包参考并使用以下扩展的部分逻辑及代码,特别感谢