记录一下困扰我很久的验证码问题,先写上显示验证码的方法,然后补上验证码验证的功能。
环境:tp5.1(实现配置虚拟域名,将www.xxx.com直接绑定到public)
tp5.1的开发手册里关于验证码的部分:
https://www.kancloud.cn/manual/thinkphp5_1/354122
1、安装插件
在项目的根目录运行下述命令:composer require topthink/think-captcha=2.*
说明: 一定要安装2.*版本,默认最新3.0版本适配tp6,这里卡了我好久。安装时间可能有点久,耐心等待即可。
2、Tool.php
编写控制器tool,实现自定义验证码方法,直接将配置的内容放进去:namespace app\admin\controller;
use think\Controller;
use think\captcha\Captcha;
class Tool extends