一、安装扩展包
composer require mews/captcha二、在config/app.php进行配置
'providers' => [ Mews\Captcha\CaptchaServiceProvider::class,//登录验证码 ], 'aliases' => [ 'Captcha' => Mews\Captcha\Facades\Captcha::class,//登录验证码 ],三、执行命令
php artisan vendor:publish四、Web端
<div class="layui-row"> <div class="layui-col-xs7"> <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label> <input type="text" name="vercode" lay-verify="required" placeholder="图形验证码" class="layui-input"> </div> <div class="layui-col-xs5"> <div style="margin-left: 10px;"> <img src="{{captcha_src('math')}}" class="layadmin-user-login-codeimg" onclick="this.src='{{captcha_src('math')}}'+ new Date().getTime()" > {{--captcha_src('flat')是应用flat规则不填为默认 default、flat、mini、math--}} </div> </div> </div>五、服务端验证
//验证码检验 $result = captcha_check($data['vercode']); if($result !== true){ return hello_error('验证码错误'); }友情链接