PHP code example of irooit / hyperf-captcha

1. Go to this page and download the library: Download irooit/hyperf-captcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

irooit / hyperf-captcha example snippets


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

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

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

// 验证
$captchaFactory->validate($key, $text);
shell
php bin/hyperf.php vendor:publish irooit/hyperf-captcha
shell
php bin/hyperf.php vendor:publish hyperf-ext/encryption
php bin/hyperf.php vendor:publish hyperf/cache