tejas/tejascaptcha

Tejas Captcha for the Laravel framework


README

The tejas/tejascaptcha is a service provider for Laravel. The package randomly generates either an alpha numeric captcha or a math captcha and provides both refresh and audio capabilities.

Section links

Preview

The preview image is not available

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

Tejas Captcha

The TejasCaptcha Service Provider is installed via Composer.

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

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

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

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

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')->middleware('tejascaptcha_verify_captcha');

The tejascaptcha Routing image is not available

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

This step is optional.

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

  • cd vendor/tejas/tejascaptcha/scripts && bash postinstall.sh && 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

This step is optional - tejas/tejascaptcha 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

    '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

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

Configuration

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

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:

<?php
return [
    'config_section_key' => 'standard',

    'standard' => [
        'length' => 5,
        'width' => 230,
        'height' => 50,
        'quality' => 90,
        'sensitive' => false,
    ],
    'flat' => [], 'mini' => [], 'inverse' => [],

    'audio' => [
        'audioFilePrefix' => 'final'
    ]
];

There are 7 keys in the config file. The config_section_key may point to one of the four pre-built image representation sections, standard is the default config_section_key value. You may override this value by setting it to 'flat', 'mini' or 'inverse'. 🔺You may also override the image selection by specifying 'flat', 'mini' or 'inverse'as a post value of tejascaptchaImageType.

🔺refer to the tejas/tejascaptcha/example/js/tejascaptcha.js file in the $('#tejas_captcha_refresh_icon') click function.

The audio key specifies the audio files name prefix.

Example Usage Only

Links