PHPackages                             charles/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. charles/captcha

ActivePackage[Validation &amp; Sanitization](/categories/validation)

charles/captcha
===============

Laravel 5 &amp; 6 &amp; 7 Captcha Package

v3.1.1(6y ago)02MITPHPPHP &gt;=7.1CI failing

Since Mar 30Pushed 6y ago1 watchersCompare

[ Source](https://github.com/watchern/laravel-cpatcha)[ Packagist](https://packagist.org/packages/charles/captcha)[ Docs](https://gitee.com/starw/captcha)[ RSS](/packages/charles-captcha/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (8)Versions (4)Used By (0)

Captcha for Laravel 5
=====================

[](#captcha-for-laravel-5)

[![Build Status](https://camo.githubusercontent.com/059f66ef89e51b775dda5384be18537e707ef24cb8a469611b4d4d8bf1b09b7d/68747470733a2f2f7472617669732d63692e6f72672f6d6577656273747564696f2f636170746368612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mewebstudio/captcha) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/fa85500631c0dba36a80e40bc3ea1ef174f1cdd632d08dd47930edb7a01af1e5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6577656273747564696f2f636170746368612f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mewebstudio/captcha/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/e3ecb233b8e0adfa95c856e5c0fcde7db78136a6fe1c17752e85f4f71b186932/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f636170746368612f762f737461626c652e737667)](https://packagist.org/packages/mews/captcha)[![Latest Unstable Version](https://camo.githubusercontent.com/f04f4956555fcebad8b051a77ccbff50abc65dfe3b2e71d89585d1b97a966f98/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f636170746368612f762f756e737461626c652e737667)](https://packagist.org/packages/mews/captcha)[![License](https://camo.githubusercontent.com/5f622a69c4b52e57bb82b9fbe114ca794524e302b15e37f1876f7c258b09a7c2/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f636170746368612f6c6963656e73652e737667)](https://packagist.org/packages/mews/captcha)[![Total Downloads](https://camo.githubusercontent.com/3c3d4e421265d3246f3e42eab65910abc6cb4eb2cb7b4c0ad6b0b124f0eda110/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f636170746368612f646f776e6c6f6164732e737667)](https://packagist.org/packages/mews/captcha)

A simple [Laravel 5/6/7](http://www.laravel.com/) service provider for including the [Captcha for Laravel](https://github.com/mewebstudio/captcha).

for Laravel 4 [Captcha for Laravel Laravel 4](https://github.com/mewebstudio/captcha/tree/master-l4)

本扩展包是基于[mewbstudio的captcha(mews/captcha)](https://github.com/mewebstudio/captcha)兼容非session情况下开发的图形验证码机制。

Preview
-------

[](#preview)

[![Preview](https://camo.githubusercontent.com/ccf2d6fadf93955be70fbfcdd356a456dea553a2fde0c1798cddf3a51661f751/68747470733a2f2f692e6962622e636f2f4b4c5163524e622f696d6167652e706e67)](https://camo.githubusercontent.com/ccf2d6fadf93955be70fbfcdd356a456dea553a2fde0c1798cddf3a51661f751/68747470733a2f2f692e6962622e636f2f4b4c5163524e622f696d6167652e706e67)

Installation
------------

[](#installation)

The Captcha Service Provider can be installed via [Composer](http://getcomposer.org) by requiring the `charles/captcha` package and setting the `minimum-stability` to `dev` (required for Laravel 5) in your project's `composer.json`.

```
{
    "require": {
        "laravel/framework": "5.0.*",
        "charles/captcha": "~3.1.0"
    },
    "minimum-stability": "dev"
}
```

or

Require this package with composer:

```
composer require charles/captcha

```

Update your packages with `composer update` or install with `composer install`.

In Windows, you'll need to include the GD2 DLL `php_gd2.dll` in php.ini. And you also need include `php_fileinfo.dll` and `php_mbstring.dll` to fit the requirements of `charles/captcha`'s dependencies.

Usage
-----

[](#usage)

To use the Captcha Service Provider, you must register the provider when bootstrapping your Laravel application. There are essentially two ways to do this.

Find the `providers` key in `config/app.php` and register the Captcha Service Provider.

```
    'providers' => [
        // ...
        'Charles\Captcha\CaptchaServiceProvider',
    ]
```

for Laravel 5.1+

```
    'providers' => [
        // ...
        Charles\Captcha\CaptchaServiceProvider::class,
    ]
```

Find the `aliases` key in `config/app.php`.

```
    'aliases' => [
        // ...
        'Captcha' => 'Charles\Captcha\Facades\Captcha',
    ]
```

for Laravel 5.1+

```
    'aliases' => [
        // ...
        'Captcha' => Charles\Captcha\Facades\Captcha::class,
    ]
```

Configuration
-------------

[](#configuration)

To use your own settings, publish config.

`$ php artisan vendor:publish`

`config/captcha.php`

```
return [
    'mode'=>'other', // 模式session或者其他任意值表示非session模式
    'lifetime' => 120, // 有效期120秒，mode为session时此项无效
    'default'   => [
        'length'    => 5,
        'width'     => 120,
        'height'    => 36,
        'quality'   => 90,
        'math'      => true, //Enable Math Captcha
    ],
    // ...
];
```

Example Usage
-------------

[](#example-usage)

```
    // [your site path]/Http/routes.php
    Route::any('captcha-test', function() {
        if (request()->getMethod() == 'POST') {
            $rules = ['captcha' => 'required|captcha'];
            $validator = validator()->make(request()->all(), $rules);
            if ($validator->fails()) {
                echo 'Incorrect!';
            } else {
                echo 'Matched :)';
            }
        }

        $form = '';
        $form .= '';
        $form .= '' . captcha_img() . '';
        $form .= '';
        $form .= 'Check';
        $form .= '';
        return $form;
    });
```

Return Image
============

[](#return-image)

```
captcha();
```

or

```
Captcha::create();
```

Return URL
==========

[](#return-url)

```
captcha_src();
```

or

```
Captcha::src('default');

```

Return HTML
===========

[](#return-html)

```
captcha_img();
```

or

```
Captcha::img();
```

To use different configurations
===============================

[](#to-use-different-configurations)

```
captcha_img('flat');

Captcha::img('inverse');
```

etc.

Based on [Intervention Image](https://github.com/Intervention/image)

^\_^

Links
-----

[](#links)

- [Intervention Image](https://github.com/Intervention/image)
- [L5 Captcha on Github](https://github.com/mewebstudio/captcha)
- [L5 Captcha on Packagist](https://packagist.org/packages/mews/captcha)
- [L5/6/7 Captcha on Github](https://gitee.com/starw/captcha)
- [L5/6/7 Captcha on Packagist](https://packagist.org/packages/charles/captcha)
- [For L4 on Github](https://github.com/mewebstudio/captcha/tree/master-l4)
- [License](http://www.opensource.org/licenses/mit-license.php)
- [Laravel website](http://laravel.com)
- [Laravel Turkiye website](http://www.laravel.gen.tr)
- [MeWebStudio website](http://www.mewebstudio.com)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~13 days

Total

3

Last Release

2213d ago

Major Versions

2.3.0 → 3.1.02020-03-31

PHP version history (2 changes)2.3.0PHP &gt;=5.4

3.1.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/73f14632584f8af1e07293b98bce9fa2bbe9f4f2881eff29b6ad46fc9c1fc244?d=identicon)[watchern](/maintainers/watchern)

---

Top Contributors

[![watchern](https://avatars.githubusercontent.com/u/53646143?v=4)](https://github.com/watchern "watchern (6 commits)")

---

Tags

captchalaravel5 Securitylaravel6 Captchalaravel6 Securitylaravel7 Captchalaravel7 Security

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/charles-captcha/health.svg)

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

###  Alternatives

[mews/captcha

Laravel 5/6/7/8/9/10/11/12 Captcha Package

2.6k5.5M84](/packages/mews-captcha)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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