手册 :https://www.kancloud.cn/manual/thinkphp5/154295
thinkphp5图形验证码Fatal error: Class 'think\captcha' not found
以下是控制器代码 :
use think\captcha\Captcha;
class Index extends Admin
{
public function loginAction()
{
$captcha = new Captcha();
$a= $captcha->entry();
echo $a;exit;
thinkphp根目录,鼠标右键此处打开命令行,执行以下命令。
composer require topthink/think-captcha
官方的5.0版本的扩展库版本号都是1.*,2.0版本均为ThinkPHP5.1版本专用。
验证码的简单用法
扩展包内定义了一些常见用法方便使用,以下示例说明
注意:需要开启URL路由。
模版内验证码的显示
<div>{:captcha_img()}</div>
或者
<div><img src="{:captcha_src()}" alt="captcha" /></div>