PHPackages                             heimuya/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. heimuya/captcha

ActivePackage

heimuya/captcha
===============

Laravel 5 Captcha Package

v2.1.9(8y ago)082MITPHPPHP &gt;=5.4

Since Jan 25Pushed 8y ago1 watchersCompare

[ Source](https://github.com/heimuya/captcha)[ Packagist](https://packagist.org/packages/heimuya/captcha)[ Docs](https://github.com/mewebstudio/captcha)[ RSS](/packages/heimuya-captcha/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (7)Versions (18)Used By (0)

Only add one useful function for SPA and wechat applications.

Due to the fact that mewebstudio is not merge pull request now, so I publish a new package. This package would delete when mewebstudio add those functions.

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)

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

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

Preview
-------

[](#preview)

[![Preview](https://camo.githubusercontent.com/e5ebfe735c8c3845df743219a60cb26c43754c66b6547dce56f8e82c64e8b261/687474703a2f2f692e696d6775722e636f6d2f485974723734342e706e67)](https://camo.githubusercontent.com/e5ebfe735c8c3845df743219a60cb26c43754c66b6547dce56f8e82c64e8b261/687474703a2f2f692e696d6775722e636f6d2f485974723734342e706e67)

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

[](#installation)

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

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

or

Require this package with composer:

```
composer require Heimuya/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 `Heimuya/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' => [
        // ...
        'Heimuya\Captcha\CaptchaServiceProvider',
    ]
```

for Laravel 5.1+

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

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

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

for Laravel 5.1+

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

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

[](#configuration)

To use your own settings, publish config.

`$ php artisan vendor:publish`

`config/captcha.php`

```
return [
    'default'   => [
        'length'    => 5,
        'width'     => 120,
        'height'    => 36,
        'quality'   => 90,
        'type'      => 'png'
    ],
    // ...
];
```

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(Input::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();

```

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

[](#return-html)

```
captcha_img();
```

or

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

Return DATA-URL for ajax or wechat application request
======================================================

[](#return-data-url-for-ajax-or-wechat-application-request)

```
captcha_data_url();
```

or

```
Captcha::create('flat')->encode('data-url')->encoded

```

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/Heimuya/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

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 54.5% 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 ~103 days

Recently: every ~55 days

Total

16

Last Release

2942d ago

Major Versions

v1.0.1 → 2.0.02015-04-12

1.0.2 → v2.1.92018-04-19

PHP version history (2 changes)v1.0.1PHP &gt;=5.3.0

2.0.0PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b29d695cd8262360d56f719d6e5553bacca428d0a3bb227aeb9fccd77026acc5?d=identicon)[heimuya](/maintainers/heimuya)

---

Top Contributors

[![mewebstudio](https://avatars.githubusercontent.com/u/2125733?v=4)](https://github.com/mewebstudio "mewebstudio (78 commits)")[![mauris](https://avatars.githubusercontent.com/u/996939?v=4)](https://github.com/mauris "mauris (33 commits)")[![sineld](https://avatars.githubusercontent.com/u/445349?v=4)](https://github.com/sineld "sineld (7 commits)")[![saidbakr](https://avatars.githubusercontent.com/u/467554?v=4)](https://github.com/saidbakr "saidbakr (5 commits)")[![heimuya](https://avatars.githubusercontent.com/u/5266605?v=4)](https://github.com/heimuya "heimuya (4 commits)")[![hutushen222](https://avatars.githubusercontent.com/u/352215?v=4)](https://github.com/hutushen222 "hutushen222 (3 commits)")[![jp7anderson](https://avatars.githubusercontent.com/u/9416588?v=4)](https://github.com/jp7anderson "jp7anderson (2 commits)")[![ocalypto](https://avatars.githubusercontent.com/u/829777?v=4)](https://github.com/ocalypto "ocalypto (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![smartpixelim](https://avatars.githubusercontent.com/u/6251872?v=4)](https://github.com/smartpixelim "smartpixelim (1 commits)")[![adamtester](https://avatars.githubusercontent.com/u/2249484?v=4)](https://github.com/adamtester "adamtester (1 commits)")[![ycrao](https://avatars.githubusercontent.com/u/3280204?v=4)](https://github.com/ycrao "ycrao (1 commits)")[![aminmazrouei](https://avatars.githubusercontent.com/u/253264094?v=4)](https://github.com/aminmazrouei "aminmazrouei (1 commits)")[![eromoe](https://avatars.githubusercontent.com/u/3938751?v=4)](https://github.com/eromoe "eromoe (1 commits)")[![howard1982](https://avatars.githubusercontent.com/u/2542216?v=4)](https://github.com/howard1982 "howard1982 (1 commits)")[![HuanMeng0](https://avatars.githubusercontent.com/u/11138015?v=4)](https://github.com/HuanMeng0 "HuanMeng0 (1 commits)")[![lbausch](https://avatars.githubusercontent.com/u/5747127?v=4)](https://github.com/lbausch "lbausch (1 commits)")[![Lin-H](https://avatars.githubusercontent.com/u/7029374?v=4)](https://github.com/Lin-H "Lin-H (1 commits)")

---

Tags

captchalaravel5 Securitylaravel5 Captcha

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mews/captcha

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

2.6k5.5M84](/packages/mews-captcha)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M73](/packages/unisharp-laravel-filemanager)[flarum/core

Delightfully simple forum software.

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

PHPackages © 2026

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