首先,先上效果图吧:

        

安装captcha:

   composer require mews/captcha 

发现5.5真的很方便,直接require包就可以了,作为LTS版,强烈建议大家用5.5.

配置验证效果:

   在config/captcha.php中有相关的配置,例如长宽,flat配置等,个人觉得使用默认配置吧,也没什么问题。

使用验证码:

      分为两个方面,前端展示验证码,后端验证验证码。

      前:
<div class="form-group{{ $errors->has('captcha') ? ' has-error' : '' }} code">
<label for="captcha" class="col-md-4 control-label">验证码</label> <div
class="col-md-6"> <input class="form-control tt-text" name="captcha" required>
{!! captcha_img() !!} @if ($errors->has('captcha')) <span class="help-block">
<strong>{{ $errors->first('captcha') }}</strong> </span> @endif </div> </div>
  后:
$this->validate($request, [ 'captcha' => 'required|captcha' ]);
       当然,你也可以获取captcha之后进行表单验证,具体看文档
<https://laravel-china.org/docs/laravel/5.5/validation/1302>吧。






友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信