PHPackages                             yuanlj-tea/slide-captcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. yuanlj-tea/slide-captcha

ActiveLibrary[Security](/categories/security)

yuanlj-tea/slide-captcha
========================

滑动验证码

v1.0.3(4y ago)96.5k—0%11MITJavaScriptPHP &gt;=7.1

Since Nov 29Pushed 4y agoCompare

[ Source](https://github.com/yuanlj-tea/slide-captcha)[ Packagist](https://packagist.org/packages/yuanlj-tea/slide-captcha)[ RSS](/packages/yuanlj-tea-slide-captcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (1)

[![](https://camo.githubusercontent.com/16ea38f69604b0bbe1c6bb7204855bf02a843aa13617fc0c1a41ffca0788c386/68747470733a2f2f747661312e73696e61696d672e636e2f6c617267652f30303753385a496c67793167686d337a716e6b66686a333065363065366a78622e6a7067)](https://camo.githubusercontent.com/16ea38f69604b0bbe1c6bb7204855bf02a843aa13617fc0c1a41ffca0788c386/68747470733a2f2f747661312e73696e61696d672e636e2f6c617267652f30303753385a496c67793167686d337a716e6b66686a333065363065366a78622e6a7067)

### Installation

[](#installation)

Use composer:

```
composer require yuanlj-tea/slide-captcha
```

### Usage

[](#usage)

You can create a slide captcha with make func:

```
use Tncode\SlideCaptcha;

$captcha = new SlideCaptcha();
$captcha->make();
```

Set logo path

```
$captcha->setLogoPath(__DIR__.'/logo/logo.png');

```

You can output captcha directly:

```
use Tncode\SlideCaptcha;

$captcha = new SlideCaptcha();
$captcha->build();
$captcha->imgout(0,1);
```

Or inline it directly in the HTML page:

```
use Tncode\SlideCaptcha;

$captcha = new SlideCaptcha();
$captcha->build();
$linlie = $captcha->getInline();
echo "";
```

You'll be able to get the code and compare it with a user input :

```
use Tncode\SlideCaptcha;

$captcha = new SlideCaptcha();
$captcha->build();
$captcha->getCode();
```

### Used in Laravel

[](#used-in-laravel)

Register ServiceProvider and Facade with config/app.php:

```
'providers' => [
    // ...
    \Tncode\SlideCaptchaServiceProvider::class,
],
'aliases' => [
    // ...
    'SlideCode' => \Tncode\SlideCaptchaFacade::class,
],
```

Get a service instance：

Method parameter injection:

```
use Tncode\SlideCaptcha;

public function getImage(Request $request, SlideCaptcha $captcha)
{

}
```

Obtained by the facade class:

```
use SlideCode;

public function getImageV1()
{
     SlideCode::build();
     $imgData = SlideCode::getInline();
     $code = SlideCode::getCode();
}
```

By service name：

```
public function getImageV2()
{
     $captcha = app('slide_captcha');
     $captcha->build();

     $imgData = $captcha->getInline();
     $code = $captcha->getCode();
}
```

Check demo:

```
public function getCaptchaDemo(Request $request, SlideCaptcha $captcha)
    {
        $key = 'slide-captcha-' . \Str::random(32);

        $captcha->build();

        \Cache::put($key, ['code' => $captcha->getCode()], 600);

        $result = [
            'captcha_key' => $key,
            'expired_at' => time() + 600,
            'captcha_image_content' => $captcha->getInline()
        ];
        return $this->responseData($result);
    }

    public function checkDemo(Request $request)
    {
        $key = $request->get('captcha_key', '');
        $code = $request->get('captcha_code', '');

        if (!\Cache::has($key)) {
            return $this->responseData('无效的key', 400);
        }

        $ret = abs(\Cache::get($key)['code'] - $code) responseData('验证成功');
        } else {
            $errKey = $key . '_error';
            $errCount = $request->session()->has($errKey) ? $request->session()->get($errKey) : 1;
            $request->session()->put($errKey, $errCount + 1);

            if ($errCount > 8) {
                \Cache::forget($key);
                $request->session()->forget($errKey);
                return $this->responseData('失败次数过多，请重新获取验证码', 400);
            }
            return $this->responseData('验证失败', 400);
        }
    }
```

Web demo:

```
see /path/vendor/yuanlj-tea/slide-captcha/src/index.html
```

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1625d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/10fba85f48f36c98b9759fdb71a2b6495d5d2a6593e12668a7121dc0f0a0c525?d=identicon)[yuanlj-tea](/maintainers/yuanlj-tea)

---

Top Contributors

[![yuanlj-tea](https://avatars.githubusercontent.com/u/20747808?v=4)](https://github.com/yuanlj-tea "yuanlj-tea (11 commits)")[![allen-xe](https://avatars.githubusercontent.com/u/49472330?v=4)](https://github.com/allen-xe "allen-xe (3 commits)")

### Embed Badge

![Health badge](/badges/yuanlj-tea-slide-captcha/health.svg)

```
[![Health](https://phpackages.com/badges/yuanlj-tea-slide-captcha/health.svg)](https://phpackages.com/packages/yuanlj-tea-slide-captcha)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
