kilofox / hyperf-captcha
A captcha component for Hyperf.
v1.0.1
2022-09-15 02:13 UTC
Requires
- php: >=7.4
- hyperf/http-message: ^2.2
- hyperf/utils: ^2.2
- psr/simple-cache: ^1.0
- symfony/string: ^5.3|^6.0
This package is auto-updated.
Last update: 2024-11-15 07:25:34 UTC
README
This is the Captcha component for Hyperf 2.
Installation
$ composer require kilofox/hyperf-captcha
Publish
$ php bin/hyperf.php vendor:publish kilofox/hyperf-captcha
Usage
Instantiate captcha factory:
use Hyperf\Utils\ApplicationContext;
use Kilofox\Captcha\CaptchaFactory;
$captchaFactory = ApplicationContext::getContainer()->get(CaptchaFactory::class);
Render a captcha:
$key = $this->request->query('key');
$captcha = $captchaFactory->create($key);
return $captcha->render();
Validate the captcha:
$key = $this->request->input('key', '');
$captcha = $this->request->input('captcha', '');
$captchaFactory->validate($key, $captcha);
Supported Captcha Styles
- alpha
- basic
- black
- math
- riddle
- word