PHPackages                             hugocabral/visualcaptcha-laravel-jquery - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hugocabral/visualcaptcha-laravel-jquery

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hugocabral/visualcaptcha-laravel-jquery
=======================================

Laravel library for visualCaptcha using jQuery. VisualCaptcha is created by EmotionLoop

61692[1 PRs](https://github.com/hugocabral/visualCaptcha-Laravel-jQuery/pulls)PHP

Since Jan 7Pushed 10y ago2 watchersCompare

[ Source](https://github.com/hugocabral/visualCaptcha-Laravel-jQuery)[ Packagist](https://packagist.org/packages/hugocabral/visualcaptcha-laravel-jquery)[ RSS](/packages/hugocabral-visualcaptcha-laravel-jquery/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

visualCaptcha Laravel jQuery
============================

[](#visualcaptcha-laravel-jquery)

A visual and cleaner alternative to the traditional text based Captcha

This is a Laravel version using jQuery of the Captcha alternative from [http://visualcaptcha.net](http://visualcaptcha.net "http://visualcaptcha.net")VisualCaptcha is the easiest to implement secure Captcha with images instead of text (and mobile-friendly).

- A better alternative to text based Captchas.
- Decrease user frustration and improve conversion rates.
- Server side validation.
- Easy to style and add custom images.
- Easily translated text.
- Can be used in Views and Controllers.

[![visualCaptcha Laravel jQuery](https://camo.githubusercontent.com/642d9e5af04344ec761b5654f297d656733ecdfd57d295e4db9632bd350d48e3/687474703a2f2f7777772e6875676f63616272616c2e70742f76697375616c436170746368612d4c61726176656c2d6a51756572792e706e67)](https://camo.githubusercontent.com/642d9e5af04344ec761b5654f297d656733ecdfd57d295e4db9632bd350d48e3/687474703a2f2f7777772e6875676f63616272616c2e70742f76697375616c436170746368612d4c61726176656c2d6a51756572792e706e67)

Pre-Requisites
--------------

[](#pre-requisites)

- Laravel
- > PHP 5.3

Installation Back-End
---------------------

[](#installation-back-end)

- Begin by installing this package through Composer.

```
{
    "require": {
		"hugocabral/visualcaptcha-laravel-jquery": "~1.0"
	}
}
```

- Add these lines top the "app.php" file in the config folder where is the "aliases" category :

```
	// app.php
	'Captcha'          => 'visualCaptcha\Captcha',
	'SessionCaptcha'   => 'visualCaptcha\SessionCaptcha',
```

- Update composer in terminal:

```
	composer update
```

### Note

[](#note)

- Example/ folder contains the app/ and public/ files used for the laravel example shown here: [http://www.hugocabral.pt/visualCaptcha-Laravel-jQuery](http://www.hugocabral.pt/visualCaptcha-Laravel-jQuery "http://www.hugocabral.pt/visualCaptcha-Laravel-jQuery")
-

Usage
-----

[](#usage)

Note: This implementation uses Localization from Laravel (Languages). No need to freak out. Its easy to use and you can check the explanation in this readme under Localization.

##### Add routes:

[](#add-routes)

```
// routes.php

		// Check Locale selected and show demo view. If your app will be English only, you can remove: $lang = Config::get('app.locale'); and remove: ,compact('lang').
		Route::get('/', array('as' => 'demo', function()
		{
		    $lang = Config::get('app.locale');
		    return View::make('demo', compact('lang'));
		}));

		// Send method to validate captcha
		Route::post('captchacheck','CaptchaController@send');

		// Routes for app.visualcaptcha.js.
		Route::group(array('prefix' => 'captcha'), function()
		{
		    Route::get('start/{howmany}', array('as' => 'captcha/start', 'uses'=>'CaptchaController@start'));
		    Route::get('audio/{type?}', array('as' => 'captcha/audio', 'uses'=>'CaptchaController@audio'));
		    Route::get('image/{index?}', array('as' => 'captcha/image', 'uses'=>'CaptchaController@image'));
		});
```

##### Create CaptchaController.php to create captcha, refresh, validade and do action (ex send email, update database)

[](#create-captchacontrollerphp-to-create-captcha-refresh-validade-and-do-action-ex-send-email-update-database)

```
// app/controllers/CaptchaController.php

		class CaptchaController extends BaseController {

		    /**
		     * Generate a Captcha
		     * @return Response
		     */
		    public function start($howmany)
		    {
		        $session = new SessionCaptcha();
		        $captcha = new Captcha($session);
		        $captcha->generate($howmany);

		        return Response::json($captcha->getFrontEndData());
		    }

		    /**
		     * Get an audio file
		     * @param  string $type Song type (mp3/ogg)
		     * @return File
		     */
		    public function audio($type = 'mp3')
		    {
		        $session = new SessionCaptcha();
		        $captcha = new Captcha($session);

		        return $captcha->streamAudio(array(), $type);
		    }

		    /**
		     * Get an image file
		     * @param  string $index Image index
		     * @return File
		     */
		    public function image($index)
		    {
		        $session = new SessionCaptcha();
		        $captcha = new Captcha($session);

		        return $captcha->streamImage(array(), $index, 0 );
		    }

		    /**
		     * Check if the Captcha result is good
		     * @return Mixed
		     */
		    public function send()
		    {

		        $data = Input::all();

		        //Validation rules
		        $rules = array(

		            'name' => 'required'
		        );

		        //Validate data
		        $validator = Validator::make($data, $rules);

		        //If everything is correct than run passes.
		        if ($validator->passes())
		        {
		            $session = new SessionCaptcha();
		            $captcha = new Captcha($session);

		            $frontendData = $captcha->getFrontendData();

		            if (!$frontendData)
		            {
		                return Redirect::back()->withInput()->withErrors(array('message' => Lang::get('text.captcha.none')));

		            } else
		            {
		                // If an image field name was submitted, try to validate it
		                if ($imageAnswer = Input::get($frontendData['imageFieldName']))
		                {
		                    if ($captcha->validateImage($imageAnswer))
		                    {
		                        // Return true if the result is correct

		                        (... DO ACTION HERE, ex send email, update db...)

		                        // This return back to form to show sucess, thats why i use status=1
		                        return Redirect::back()->with('status', 1);

		                    } else
		                    {
		                        return Redirect::back()->withInput()->withErrors(array('message' => Lang::get('text.captcha.image')));

		                    }
		                } else if ($audioAnswer = Input::get($frontendData['audioFieldName']))
		                {
		                    if ($captcha->validateAudio($audioAnswer))
		                    {
		                        // Return true if the result is correct

		                        (... DO ACTION HERE, ex send email, update db...)

		                         // This return back to form to show sucess, thats why i use status=1
		                        return Redirect::back()->with('status', 1);

		                    } else
		                    {
		                        return Redirect::back()->withInput()->withErrors(array('message' => Lang::get('text.captcha.audio')));

		                    }
		                } else
		                {
		                    return Redirect::back()->withInput()->withErrors(array('message' => Lang::get('text.captcha.incomplete')));

		                }
		            }

		        } else
		        {
		            //return "contact form with errors";
		            return Redirect::back()->withErrors($validator)->with('status', 2);;

		        }

		    }
		}
```

Note: The Lang::get('xxx.xxx.xxx') code is the implementation of Localization (Languages). If your app will be English only, you can hardcore and replace this with your messages/errors.

##### Include jQuery library, jQuery visualCaptcha front-end library and app.js in you view or main layout or wherever you will be using visualCaptcha

[](#include-jquery-library-jquery-visualcaptcha-front-end-library-and-appjs-in-you-view-or-main-layout-or-wherever-you-will-be-using-visualcaptcha)

```
// contact.blade.php
{{ HTML::script(js/jquery.min.js) }}
{{ HTML::script(js/visualcaptcha.jquery.js) }}
{{ HTML::script(js/app.js') }}) }}
```

README INCOMPLETE / will finish soon
------------------------------------

[](#readme-incomplete--will-finish-soon)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4cda4a2f065b85e1cf71b0dcf980c4388479031f7d976d8c9c58fec0df9e0d93?d=identicon)[hugocabral](/maintainers/hugocabral)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/hugocabral-visualcaptcha-laravel-jquery/health.svg)

```
[![Health](https://phpackages.com/badges/hugocabral-visualcaptcha-laravel-jquery/health.svg)](https://phpackages.com/packages/hugocabral-visualcaptcha-laravel-jquery)
```

###  Alternatives

[smalls/video-tools

短视频的拓展包，集成各大短视频的去水印功能

6868.8k](/packages/smalls-video-tools)

PHPackages © 2026

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