PHP code example of yokov / captcha

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

    

yokov / captcha example snippets


$config = [
    // 验证码字符类型
    'charType'          => 'default',
    // 验证码长度
    'length'            => 4,
    // 是否是 gif 动态图
    'isGif'             => false,
    // 动图帧率
    'gifFps'            => 12,
    // 图片宽度
    'width'             => 150,
    // 图片高度
    'height'            => 40,
    // 字体文件路径
    'fontPath'          => '',
    // 字体大小
    'fontSize'          => 24,
];

$builder = new \Yokov\Captcha\CaptchaBuilder($config);

// 获取验证码字符串
$builder->getChar();

// 生成验证码图片
$builder->build();