PHP code example of joshuavanderpoll / laravel-captchas

1. Go to this page and download the library: Download joshuavanderpoll/laravel-captchas 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/ */

    

joshuavanderpoll / laravel-captchas example snippets


'default' => 'tiles', // or 'broken_circle', 'scatter', 'rotate', 'slider', 'grid'

'default' => ['tiles', 'scatter', 'rotate'],
// or per gate:
'gate' => ['challenge' => ['tiles', 'scatter', 'rotate']],

// routes/console.php (or app/Console/Kernel.php)
use Illuminate\Support\Facades\Schedule;

Schedule::command('captchas:refresh-lists')->daily();

$request->validate([
    'cap_token' => '

Route::get('/gate', fn () => view('captchas::captcha', ['action' => route('gate.check')]))->name('gate');

Route::post('/gate', function (Illuminate\Http\Request $request) {
    $request->validate(['cap_token' => '

return view('captchas::captcha', [
    'action' => route('gate.check'),
    'error'  => __('captchas::captchas.failed'),
]);

Route::middleware('captcha.gate')->group(function () {
    Route::get('/', HomeController::class);
});

use JoshuaVanderpoll\Captchas\Facades\Captcha;

$captcha = Captcha::make();   // GeneratedCaptcha { token, image, prompt, ttl }

$ok = Captcha::verify($captcha->token, $request->all());

'challenges' => [
    'tiles' => ['paths' => [resource_path('captcha/landscapes')]],
    'grid'  => ['path'  => resource_path('captcha/grid')], // sub-folder per word
],
bash
php artisan vendor:publish --tag=captchas-config
php artisan vendor:publish --tag=captchas-views
php artisan vendor:publish --tag=captchas-lang
bash
php artisan captchas:refresh-lists
jsonc
// composer.json - refresh on every composer install/update
"scripts": {
    "post-update-cmd": [
        "@php artisan captchas:refresh-lists --ansi"
    ]
}
blade
<form action="{{ route('register.store') }}" method="post">
    @csrf

    {{-- your fields --}}

    @