Download the PHP package gitzwt/think-captcha-1.1 without Composer

On this page you can find all versions of the php package gitzwt/think-captcha-1.1. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package think-captcha-1.1

think-captcha-1.1

thinkphp5.0 验证码类库(修改版)

修改部分,新增cache缓存存储验证码信息(便于api接口调用使用)

安装

composer require gitzwt/think-captcha-1.1

/**
     * 获取图片验证码(接口调用示例,type为cache时)
     * @return \think\response\Json
     */
    public function getCaptcha()
    {
        $captcha_id = Strs::randString(4, 1) . date('s'); //生成随机id
        //接口构建类的返回
        return $this->buildSuccess([
            'CaptchaId' => (String)$captcha_id, //captcha_id
            'CaptchaSrc' => $this->request->domain() . captcha_src($captcha_id) //验证码url
        ]);
    }

使用

extra子目录内配置 captcha.php

参数 描述 默认
codeSet 验证码字符集合
expire 验证码过期时间(s) 1800
useZh 使用中文验证码 false
zhSet 中文验证码字符串
useImgBg 使用背景图片 false
fontSize 验证码字体大小(px) 25
useCurve 是否画混淆曲线 true
useNoise 是否添加杂点 true
imageH 验证码图片高度,设置为0为自动计算 0
imageW 验证码图片宽度,设置为0为自动计算 0
length 验证码位数 5
fontttf 验证码字体,不设置是随机获取
bg 背景颜色 [243, 251, 254]
reset 验证成功后是否重置 true
type 验证码存储驱动类型,支持session和cache 默认cache

模板里输出验证码

<div>{:captcha_img()}</div>

或者

<div><img src="{:captcha_src()}" alt="captcha" /></div>

上面两种的最终效果是一样的

控制器里验证

使用TP5的内置验证功能即可

$this->validate($data,[
    'captcha|验证码'=>'required|captcha'
]);

或者手动验证

if(!captcha_check($captcha)){
 //验证失败
};

具体使用参照tp5.0完全开发手册验证码部分


All versions of think-captcha-1.1 with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gitzwt/think-captcha-1.1 contains the following files

Loading the files please wait ....