Laravel中使用验证码

作者: 吴杰 分类: 编程 发布时间: 2024-12-09 09:45

在Laravel中如果需要验证码,可以使用mews/captcha库来实现,过程如下 :

安装:

composer require "mews/captcha"

发布配置文件:

php artisan vendor:publish

前端引用:

<img src="{{captcha_src()}}" style="cursor: pointer" onclick="this.src='{{captcha_src()}}'+Math.random()">

注意,项目路径不能有中文,否则会报错:ErrorException: imagettfbbox(): Could not find/open font

简单吧,这就是生态强大的好处。