GithubHelp home page GithubHelp logo

captcha's Introduction

captcha

一个 PHP 验证码库

Fork from yokov/captcha and fix some bug.

安装

$ composer require sobyte/captcha -vvv

使用

$config = [
    // 验证码字符类型
    'charType'          => 'default',
    // 验证码长度
    'length'            => 4,
    // 是否是 gif 动态图
    'isGif'             => false,
    // 动图帧率
    'gifFps'            => 12,
    // 图片宽度
    'width'             => 150,
    // 图片高度
    'height'            => 40,
    // 字体文件路径
    'fontPath'          => '',
    // 字体大小
    'fontSize'          => 24,
];

$builder = new \Sobyte\Captcha\CaptchaBuilder($config);

// 获取验证码字符串
$builder->getChar();

// 生成验证码图片
$builder->build();

部分设置

  • 验证码字符类型

    1. default: 大小写字母和数字混合
    2. only_char: 只有大小写字母
    3. only_number: 只有数字
  • 字体文件

    • 注:可自定义字体文件,fontPath 配置相应的字体文件路径即可

    • 库中内置 9 种字体(fontPath 设置 1-9 可分别指定相应的字体)

    字体序号 静态样式 动图
    1 font-1 gif-font-1
    2 font-2 gif-font-2
    3 font-3 gif-font-3
    4 font-4 gif-font-4
    5 font-5 gif-font-5
    6 font-6 gif-font-6
    7 font-7 gif-font-7
    8 font-8 gif-font-8
    9 font-9 gif-font-9

License

MIT

captcha's People

Contributors

mingo6 avatar yokov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.