PHP code example of gts-meghni / laravel-captcha

1. Go to this page and download the library: Download gts-meghni/laravel-captcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gts-meghni / laravel-captcha example snippets


'driver' => 'gd',   // gd | imagick

use GtsMeghni\LaravelCaptcha\Validation\Rules\ProofOfWork;

'pow_token' => ['

'pow' => [
    'enabled' => true,
    'difficulty' => 16,        // floor everyone pays
    'escalate' => true,
    'step' => 2,               // bits per recorded failure
    'max_difficulty' => 24,    // ceiling
    'volume' => [
        'every' => 20,         // challenges requested
        'step' => 2,           // bits added per that many
    ],
    'expire' => 120,
],

use GtsMeghni\LaravelCaptcha\Validation\Rules\Captcha;

'captcha_token' => ['

'fields' => ['token' => 'recaptchaToken', 'answer' => 'userInput'],

app(ChallengeManager::class)->extend('words', new WordChallenge);

// config/captcha.php
'phrase' => ['type' => 'words', 'width' => 260],

'min_seconds' => 1.5,   // refuse answers faster than a person could give
'bind_ip' => false,     // 

$key = 'login:'.$request->input('email');

$rules = [
    'pow_token' => ['a:: ['d
Captcha::clearFailures($key);   // correct password, clears both counters

'escalation' => [
    'after' => 2,     // failures tolerated before a challenge is demanded
    'decay' => 900,   // seconds a failure is remembered
],

Schedule::command('captcha:prune')->hourly();
bash
php artisan vendor:publish --tag="laravel-captcha"
bash
php artisan vendor:publish --tag="laravel-captcha-config"
php artisan vendor:publish --tag="laravel-captcha-lang"
php artisan vendor:publish --tag="laravel-captcha-fonts"
php artisan vendor:publish --tag="laravel-captcha-backgrounds"