Download the PHP package edward1108/edward-captcha without Composer
On this page you can find all versions of the php package edward1108/edward-captcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download edward1108/edward-captcha
More information about edward1108/edward-captcha
Files in edward1108/edward-captcha
Download edward1108/edward-captcha
More information about edward1108/edward-captcha
Files in edward1108/edward-captcha
Vendor edward1108
Package edward-captcha
Short Description ThinkPHP6验证码(图片、短信)支持api友好化
License MIT
Homepage https://github.com/Edward1108/edward-captcha
Package edward-captcha
Short Description ThinkPHP6验证码(图片、短信)支持api友好化
License MIT
Homepage https://github.com/Edward1108/edward-captcha
Please rate this library. Is it a good library?
Informations about the package edward-captcha
edward-captcha
说明
ThinkPHP6 验证码类库,支持H5和API接口下使用。如果项目有安装官方的topthink/think-captcha,请先卸载,卸载请执行:composer remove topthink/think-captcha
,然后再安装此包。
安装
composer require edward1108/edward-captcha
API接口下使用
图片验证码
1-生成图片验证码
2-验证图片验证码
短信验证码
1-生成短信验证码
2-验证短信验证码
非API接口下使用
基于think-captcha进行扩展,保留了think-captcha所有功能,用于非前后端分离项目
在控制器中输出验证码
在控制器的操作方法中使用
public function captcha($id = '')
{
return captcha($id);
}
然后注册对应的路由来输出验证码
模板里输出验证码
首先要在你应用的路由定义文件中,注册一个验证码路由规则。
\think\facade\Route::get('captcha/[:id]', "\\edward\\captcha\\CaptchaController@index");
然后就可以在模板文件中使用
<div>{:captcha_img()}</div>
或者
<div><img src="{:captcha_src()}" alt="captcha" /></div>
上面两种的最终效果是一样的
控制器里验证
使用TP的内置验证功能即可
$this->validate($data,[
'captcha|验证码'=>'require|captcha'
]);
或者手动验证
if(!captcha_check($captcha)){
//验证失败
};
All versions of edward-captcha with dependencies
PHP Build Version
Package Version
The package edward1108/edward-captcha contains the following files
Loading the files please wait ....