Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhuchunshu/hyperf-captcha
hyperf-captcha
https://github.com/zhuchunshu/hyperf-captcha
Last synced: about 2 months ago
JSON representation
hyperf-captcha
- Host: GitHub
- URL: https://github.com/zhuchunshu/hyperf-captcha
- Owner: zhuchunshu
- License: mit
- Created: 2023-02-06T11:26:46.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-06T16:33:35.000Z (almost 2 years ago)
- Last Synced: 2024-04-23T16:21:12.616Z (8 months ago)
- Language: PHP
- Size: 155 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Captcha for Hyperf
##### This is the Captcha component for Hyperf 2.
## 安装
```shell
composer require zhuchunshu/hyperf-captcha
```## 发布配置
```shell
php bin/hyperf.php vendor:publish zhuchunshu/hyperf-captcha
```> 字体文件默认发布到 `/resources/fonts` 目录。
组件依赖 `hyperf-ext/encryption` 组件加解密 `key`,依赖 `hyperf/cache` 组件暂存使用过的 `key`,您需要发布这些组件的配置:
```shell
php bin/hyperf.php vendor:publish hyperf-ext/encryption
php bin/hyperf.php vendor:publish hyperf/cache
```## 使用
```php
use Hyperf\Utils\ApplicationContext;
use Inkedus\Captcha\CaptchaFactory;$captchaFactory = ApplicationContext::getContainer()->get(CaptchaFactory::class);
// 生成
$captcha = $captchaFactory->make();// 验证
$captchaFactory->validate($key, $text);
```#### 本包参考并使用以下扩展的部分逻辑及代码,特别感谢
* [Intervention Image](https://github.com/Intervention/image)
* [Mewebstudio Captcha](https://github.com/mewebstudio/captcha)
* [hyperf-ext/captcha](https://github.com/hyperf-ext/captcha)