PHP code example of risentang / lumen-captcha

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

    

risentang / lumen-captcha example snippets


    //验证码
    $app->register(Risentang\LumenCaptcha\CaptchaServiceProvider::class);
    class_alias('Risentang\LumenCaptcha\Facades\Captcha','Captcha');

/**
 * captcha配置
 */
config(['captcha'=>
    [
        'useful_time'=>5,//验证码有效时间,单位(分钟)
        'captcha_characters'=>'2346789abcdefghjmnpqrtuxyzABCDEFGHJMNPQRTUXYZ',
        'sensitive' =>false,//验证码大小写是否敏感
        'login'   => [//登陆验证码样式
            'length'    => 4,//验证码字数
            'width'     => 120,//图片宽度
            'height'    => 36,//字体大小和图片高度
            'angle'    => 10,//验证码中字体倾斜度
            'lines'    => 2,//生成横线条数
            'quality'   => 90,//品质
            'invert'    =>false,//反相
            'bgImage'   =>true,//是否有背景图
            'bgColor'   =>'#ffffff',
            'blur'   =>0,//模糊度
            'sharpen'   =>0,//锐化
            'contrast'   =>0,//反差
            'fontColors'=>['#339900','#ff3300','#9966ff','#3333ff'],//字体颜色
        ],
    ]
]);

public function checkCaptcha(Request $request, $type = 'default',$captchaUuid)
    {
        $this->validate($request,[
            'captcha'=>'

{站点域名}/captchaInfo/{type?}