PHPackages                             tejas/tejascaptcha - 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. tejas/tejascaptcha

ActivePackage[Security](/categories/security)

tejas/tejascaptcha
==================

Tejas Captcha for the Laravel framework

1.0.12.55(4y ago)0141MITPHPPHP &gt;=7.0

Since Apr 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/1007tejas/tejascaptcha)[ Packagist](https://packagist.org/packages/tejas/tejascaptcha)[ Docs](https://github.com/1007tejas/tejascaptcha)[ RSS](/packages/tejas-tejascaptcha/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (4)Versions (81)Used By (0)

Tejas Captcha for the Laravel framework
=======================================

[](#tejas-captcha-for-the-laravel-framework)

The tejas/tejascaptcha is a service provider for [Laravel](http://www.laravel.com). The package randomly generates either an alpha numeric captcha or a math captcha and provides both refresh and audio capabilities.

Section links
-------------

[](#section-links)

- [Preview](#preview)
- [Compatibility](#compatibility)
- [Installation](#installation)

    - [Tejas Captcha](#tejas-captcha)
    - [Tejas Captcha Middleware - Captcha Verification](#tejas-captcha-middleware---captcha-verification)
    - [Bootstrap - Laravel Installation](#bootstrap---laravel-installation)
    - [Tejas Captcha Makefile - Post Install](#tejas-captcha-makefile---post-install)
    - [Register the Tejas Captcha service provider](#register-the-tejas-captcha-service-provider)
- [Configuration](#configuration)

    - [Publish the configuration file](#publish-the-configuration-file)

Preview
-------

[](#preview)

[![The preview image is not available](assets/githubReadme/images/tejasCaptchaPreview.png?raw=true "TejasCaptcha Preview")](assets/githubReadme/images/tejasCaptchaPreview.png?raw=true)

Compatibility
-------------

[](#compatibility)

The tejas/tejascaptcha service provider has been tested with Laravel versions 5, 6 and 7. Test were performed on a Linux / Debian / Apache2 web server.

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

[](#installation)

### Tejas Captcha

[](#tejas-captcha)

The TejasCaptcha Service Provider is installed via [Composer](http://getcomposer.org).

From your projects root directory, open a terminal and run the command

- `composer require tejas/tejascaptcha`
- `npm install bootstrap`
- `npm install @fortawesome/fontawesome-free`

[![The composer require cmd image is not available](assets/githubReadme/images/tejasCaptchaComposerRequireCmd.png?raw=true "TejasCaptcha Composer Require Cmd")](assets/githubReadme/images/tejasCaptchaComposerRequireCmd.png?raw=true)

### Tejas Captcha Middleware - Captcha Verification

[](#tejas-captcha-middleware---captcha-verification)

**app/Http/Middleware/VerifyTejasCaptcha.php**

Middleware is used to verify that the captcha was correctly entered.

From your projects root directory, open a terminal and run the command:

- `cp vendor/tejas/tejascaptcha/src/app/Http/Middleware/VerifyTejasCaptcha.php app/Http/Middleware/`.

This command copies the `VerifyTejasCaptcha.php` middleware stub file to your projects `app/Http/Middleware` folder.

```
namespace App\Http\Middleware;

use Tejas\TejasCaptcha\Http\Middleware\VerifyTejasCaptcha as Middleware;

class VerifyTejasCaptcha extends Middleware
{
    /*
      Uses the tejas/tejascaptcha service providers middleware
    */
}

```

[![The tejascaptcha middleware image is not available](assets/githubReadme/images/tejasCaptchaVerifyMiddlewareStub.png?raw=true "TejasCaptcha Middleware")](assets/githubReadme/images/tejasCaptchaVerifyMiddlewareStub.png?raw=true)

**app/Http/Kernel.php**

In the `app/Http/Kernel.php` file at the bottom of the `routeMiddleware` section insert the following line:

- `'tejascaptcha_verify_captcha' => \App\Http\Middleware\VerifyTejasCaptcha::class,`

[![The tejascaptcha middleware Kernel file image is not available](assets/githubReadme/images/tejasCaptchaMiddlewareKernel.png?raw=true "TejasCaptcha Middleware Kernel file")](assets/githubReadme/images/tejasCaptchaMiddlewareKernel.png?raw=true)

Use this middleware declaration wherever the tejas/tejascaptcha is included in the Post submission.

**example/routes/web.php**

##### Example form submission route using tejascaptcha middleware

[](#example-form-submission-route-using-tejascaptcha-middleware)

This route is declared in the `example/routes/web.php` file. It is part of the working example files included with the Tejas Captcha package. See example/README.md for implementation details.

##### Route::post('tejascaptcha\_verify\_form','TejasCaptcha\_Controller@tejasCaptcha')-&gt;middleware('tejascaptcha\_verify\_captcha');

[](#routeposttejascaptcha_verify_formtejascaptcha_controllertejascaptcha-middlewaretejascaptcha_verify_captcha)

[![The tejascaptcha Routing image is not available](assets/githubReadme/images/tejasCaptchaMiddlewareRoute.png?raw=true "TejasCaptcha Middleware Route")](assets/githubReadme/images/tejasCaptchaMiddlewareRoute.png?raw=true)

### Bootstrap - Laravel Installation

[](#bootstrap---laravel-installation)

Open a terminal, navigate to your projects root directory and run:

- `composer require laravel/ui`
- `php artisan ui bootstrap`
    - Alternatively if you also want the auth scaffoldings: `php artisan ui bootstrap --auth`
- `npm install && npm run dev`

### Tejas Captcha Makefile - Post Install

[](#tejas-captcha-makefile---post-install)

##### This step is optional.

[](#this-step-is-optional)

To install the included Makefile run this from your projects root directory.

- cd vendor/tejas/tejascaptcha/scripts &amp;&amp; bash postinstall.sh &amp;&amp; cd ../../../../

The Makefile is installed inside the tejascaptcha directory in your projects root.

To run the tejascaptcha/Makefile after installing it; From your projects root directory run the following command with one of the specified make actions:

- make -C tejascaptcha \[ install update test remove show\_version \]

### Register the Tejas Captcha service provider

[](#register-the-tejas-captcha-service-provider)

##### This step is optional - tejas/tejascaptcha is registered automatically by Composer package discovery.

[](#this-step-is-optional---tejastejascaptcha-is-registered-automatically-by-composer-package-discovery)

**config/app.php**

Register the `tejas/tejascaptcha` service provider under the `providers` key in `config/app.php`.

[![The service providers image is not available](assets/githubReadme/images/tejasCaptchaProvider1.png?raw=true "TejasCaptcha Service Provider")](assets/githubReadme/images/tejasCaptchaProvider1.png?raw=true)

```
    'providers' => [
        Tejas\TejasCaptcha\TejasCaptchaServiceProvider::class,
    ]
```

Register the `tejas/tejascaptcha` service providers alias under the `aliases` key in `config/app.php`.

[![The service providers alias image is not available](assets/githubReadme/images/tejasCaptchaProvider3.png?raw=true "TejasCaptcha Service Providers Alias")](assets/githubReadme/images/tejasCaptchaProvider3.png?raw=true)

```
    'aliases' => [
        'TejasCaptcha' => Tejas\TejasCaptcha\Facades\TejasCaptcha::class,
    ]
```

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

[](#configuration)

### Publish the configuration file

[](#publish-the-configuration-file)

**config/tejascaptcha.php**

To customize tejas/tejascaptcha's settings run Laravels `vendor:publish` artisan command from your projects root directory.

```
$ php artisan vendor:publish

```

Example output:

[![The vendor publish image is not available](assets/githubReadme/images/tejasCaptchaVendorPublish.png?raw=true "Vendor Publish")](assets/githubReadme/images/tejasCaptchaVendorPublish.png?raw=true)

Type the number associated with tejascaptcha service provider and press enter. An editable copy of tejas/tejascaptcha's config file, `tejascaptcha.php`, should have been copied to your projects `config` directory.

Abbreviated default config file:

```
