TP5 Fatal error: Class 'think\Route' not found

1、使用验证码了时:使用Composer安装think-captcha扩展包:

composer require topthink/think-captcha

报错:Fatal error: Class 'Route' not found in D:\WWW\JVS\tp5\vendor\topthink\think-captcha\src\helper.php on line 12

TP5 Fatal error: Class 'think\Route' not found_第1张图片

查看代码:


// +----------------------------------------------------------------------

Route::get('captcha/[:id]', "\\think\\captcha\\CaptchaController@index");

Validate::extend('captcha', function ($value, $id = '') {
    return captcha_check($value, $id);
});

Validate::setTypeMsg('captcha', ':attribute错误!');

修改为:


// +----------------------------------------------------------------------

\think\Route::get('captcha/[:id]', "\\think\\captcha\\CaptchaController@index");

\think\Validate::extend('captcha', function ($value, $id = "") {
    return captcha_check($value, $id, (array)\think\Config::get('captcha'));
});

\think\Validate::setTypeMsg('captcha', '验证码错误!');

就可以访问了。

 

 

 

你可能感兴趣的:(Thinkphp)