PHP code example of zhuchunshu / hyperf-captcha

1. Go to this page and download the library: Download zhuchunshu/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/ */

    

zhuchunshu / hyperf-captcha example snippets


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

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

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

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